In this notebook, we'll look into modelling implied trading within an exchange. Implied trading refers to ability to connect liquidity on strategy and outright order books (e.g. Euronext).

1 Type definitions and printers

1.1 Model type definitions

Our first goal is to setup the various type definitions that we'll use later on.

In [1]:
type side = BUY | SELL

type outright_id = OUT1 | OUT2 | OUT3
type strategy_id = STRAT1 | STRAT2
type month = Mar | Jun | Sep | Dec

(* Map an outright with an expiry *)
let contract_expiry = function
  | OUT1 -> Mar
  | OUT2 -> Jun
  | OUT3 -> Sep

(* Convert month to an integer *)
let month_to_int = function
  | Mar -> 3
  | Jun -> 6
  | Sep -> 9
  | Dec -> 12
;;

(* Return true of m1 is nearer (or equal) to m2 *)
let month_comp (m1 : month) (m2 : month) =
  (month_to_int m1) < (month_to_int  m2)
;;

type instrument =
  | Strategy of strategy_id
  | Outright of outright_id
    
(* Level information *)
type level_info = {
  li_qty : int
  ; li_price : int
}

(* best bid and ask information *)
type best_bid_ask = {
  bid_info : level_info option
  ; ask_info : level_info option
}

(* Best bid/ask for all of the books *)
type books_info = {
  book1 : best_bid_ask
  ; book2 : best_bid_ask
  ; book3 : best_bid_ask
}

(* Order type *)
type order = {
  o_qty : int
  ; o_price : int
  ; o_time : int
  ; o_id : int
  ; o_side : side
  ; o_client_id : int
  ; o_inst : instrument
  ; o_is_implied : bool
}

(* Helper function to make order creation simpler *)
let make si qty price id inst clientid isimp time =
  {o_qty = qty ; o_price = price; o_id = id; o_side = si; 
   o_client_id = clientid; o_inst = inst; o_is_implied = isimp;
   o_time = time }


(* outright order book *)
type book = {
  b_buys : order list
  ; b_sells : order list
}

let empty_book = { b_buys = []; b_sells = [] }
    
(* Individual leg *)
type leg = {
  leg_sec_idx : outright_id
  ; leg_mult : int
}

(* Strategy is composed of legs *)
type strategy = {
  time_created : int
  ; leg1 : leg
  ; leg2 : leg
  ; leg3 : leg
}

(* Helper function to make strategy creation smaller *)
let make_strat tcreated m1 m2 m3 = {
  time_created = tcreated
  ; leg1 = { leg_sec_idx = OUT1; leg_mult = m1 }
  ; leg2 = { leg_sec_idx = OUT2; leg_mult = m2 }
  ; leg3 = { leg_sec_idx = OUT3; leg_mult = m3 } 
}

type implied_strat_ord = {
  max_strat : int option
  ; strat_price : int option
}

(* New order message *)
type new_ord_msg = {
  no_client_id : int
  ; no_inst_type : instrument
  ; no_qty : int
  ; no_side : side
  ; no_price : int
}

(* cancel order ID *)
type cancel_ord_msg = {
  co_client_id : int
  ; co_order_id : int
  ; co_instrument : instrument
  ; co_side : side
}

(* Inbound messages type *)
type inbound_msg = 
  | NewOrder of new_ord_msg
  | CancelOrder of cancel_ord_msg
  | ImpliedUncross

(* Helper function for creating new order messages *)
let make_no_msg cid inst qty sd p =
 NewOrder {
  no_client_id = cid
  ; no_inst_type = inst
  ; no_qty = qty
  ; no_side = sd
  ; no_price = p
 }

(* ack message *)
type ack_msg = {
  ack_client_id : int
  ; ack_order_id : int
  ; ack_inst_type : instrument
  ; ack_qty : int
  ; ack_side : side
  ; ack_price : int
}

(* fill information *)
type fill = {
  fill_client_id : int
  ; fill_qty : int
  ; fill_price : int
  ; fill_order_id : int
  ; fill_order_done : bool
}

(* uncross result *)
type uncross_res = {
  uncrossed_book : book
  ; uncrossed_fills : fill list
  ; uncrossed_qty : int
}

(* outbound message type *)
type outbound_msg = 
  | Ack of ack_msg
  | Fill of fill
  | UncrossResult of uncross_res
;;

(* The entire market - strategy definitions, order books, messages, etc. s*)
type market = {

  (* current time*)
  curr_time : int

  (* used for order ID counter *)
  ; last_ord_id : int

  (* two strategy definitions *)
  ; strat1    : strategy
  ; strat2    : strategy

  (* outright books *)
  ; out_book1 : book
  ; out_book2 : book
  ; out_book3 : book

  (* strategy books *)
  ; s_book1   : book
  ; s_book2   : book

  (* inbound and outbound message queues *)
  ; inbound_msgs  : inbound_msg list
  ; outbound_msgs : outbound_msg list

}
Out[1]:
type side = BUY | SELL
type outright_id = OUT1 | OUT2 | OUT3
type strategy_id = STRAT1 | STRAT2
type month = Mar | Jun | Sep | Dec
val contract_expiry : outright_id -> month = <fun>
val month_to_int : month -> int = <fun>
val month_comp : month -> month -> bool = <fun>
type instrument = Strategy of strategy_id | Outright of outright_id
type level_info = { li_qty : int; li_price : int; }
type best_bid_ask = {
  bid_info : level_info option;
  ask_info : level_info option;
}
type books_info = {
  book1 : best_bid_ask;
  book2 : best_bid_ask;
  book3 : best_bid_ask;
}
type order = {
  o_qty : int;
  o_price : int;
  o_time : int;
  o_id : int;
  o_side : side;
  o_client_id : int;
  o_inst : instrument;
  o_is_implied : bool;
}
val make :
  side -> int -> int -> int -> instrument -> int -> bool -> int -> order =
  <fun>
type book = { b_buys : order list; b_sells : order list; }
val empty_book : book = {b_buys = []; b_sells = []}
type leg = { leg_sec_idx : outright_id; leg_mult : int; }
type strategy = { time_created : int; leg1 : leg; leg2 : leg; leg3 : leg; }
val make_strat : int -> int -> int -> int -> strategy = <fun>
type implied_strat_ord = {
  max_strat : int option;
  strat_price : int option;
}
type new_ord_msg = {
  no_client_id : int;
  no_inst_type : instrument;
  no_qty : int;
  no_side : side;
  no_price : int;
}
type cancel_ord_msg = {
  co_client_id : int;
  co_order_id : int;
  co_instrument : instrument;
  co_side : side;
}
type inbound_msg =
    NewOrder of new_ord_msg
  | CancelOrder of cancel_ord_msg
  | ImpliedUncross
val make_no_msg : int -> instrument -> int -> side -> int -> inbound_msg =
  <fun>
type ack_msg = {
  ack_client_id : int;
  ack_order_id : int;
  ack_inst_type : instrument;
  ack_qty : int;
  ack_side : side;
  ack_price : int;
}
type fill = {
  fill_client_id : int;
  fill_qty : int;
  fill_price : int;
  fill_order_id : int;
  fill_order_done : bool;
}
type uncross_res = {
  uncrossed_book : book;
  uncrossed_fills : fill list;
  uncrossed_qty : int;
}
type outbound_msg =
    Ack of ack_msg
  | Fill of fill
  | UncrossResult of uncross_res
type market = {
  curr_time : int;
  last_ord_id : int;
  strat1 : strategy;
  strat2 : strategy;
  out_book1 : book;
  out_book2 : book;
  out_book3 : book;
  s_book1 : book;
  s_book2 : book;
  inbound_msgs : inbound_msg list;
  outbound_msgs : outbound_msg list;
}

1.2 Custom type printers

One of Imandra's powerful features is the ability to combine logic (pure subset of OCaml) and program (all of OCaml) modes. In the following cell, we will create and install a custom type printer (HTML) for an order book. So that next time a value of this type is computed within a cell, this printer would be used instead of the generic one.

In [2]:
(* Here's an example of a custom printer that we can install for arbitrary data types. *)

#program;;
#require "tyxml";;
let html_of_order (o : order) =
  let module H = Tyxml.Html in
  H.div
  ~a:(if o.o_is_implied then [H.a_style "color: red"] else [])
  [ H.div 
    ~a:[H.a_style "font-size: 1.4em"]
    [H.txt (Format.asprintf "%s (%s)" (Z.to_string o.o_price) (Z.to_string o.o_qty))]
  ; H.div (if o.o_is_implied then [H.txt "Implied"] else [])
  ]
  
let doc_of_order (o:order) =
  let module H = Tyxml.Html in
  Document.html (H.div [html_of_order o]);;
  
#install_doc doc_of_order

let html_of_book ?(title="") (b: book) =
  let module H = Tyxml.Html in
  let rec build_rows acc buys sells =
      match buys, sells with
      | b :: bs, s :: ss -> build_rows (acc @ [H.tr [H.td [html_of_order b]; H.td [html_of_order s]]]) bs ss
      | b :: bs, [] -> build_rows (acc @ [H.tr [H.td [html_of_order b]; H.td [H.txt "-"]]]) bs []
      | [], s :: ss -> build_rows (acc @ [H.tr [H.td [H.txt "-"]; H.td [html_of_order s]]]) [] ss
      | [], [] -> acc
  in
  H.div 
  ~a:[H.a_style "margin-right:1em; display: flex; flex-direction: column; align-items: center; justify-content: flex-start"]
  [ H.div ~a:[H.a_style "font-weight: bold"] [H.txt title]
  ; H.table
    ~thead:(H.thead [H.tr [H.th [H.txt "Buys"]; H.th [H.txt "Sells"]]])
    (build_rows [] b.b_buys b.b_sells)]
  
let doc_of_book (b:book) =
  let module H = Tyxml.Html in
  Document.html (H.div [html_of_book ~title:"M1 Mar21" b]);;
  
#install_doc doc_of_book;;

let html_of_market (m: market) =
  let module H = Tyxml.Html in
  H.div 
  [ H.div ~a:[H.a_style "display: flex"]
    [ html_of_book ~title:"Strategy 1" m.s_book1 
    ; html_of_book ~title:"Strategy 2" m.s_book2
    ]
  ; H.div ~a:[H.a_style "margin-top: 1em; display: flex"]
    [ html_of_book ~title:"Book 1" m.out_book1 
    ; html_of_book ~title:"Book 2" m.out_book2
    ; html_of_book ~title:"Book 3" m.out_book3
    ]]
    
let doc_of_market (m : market) =
  let module H = Tyxml.Html in
  Document.html (html_of_market m);;
  
#install_doc doc_of_market;;

#logic;;
Out[2]:
- : unit = ()
val html_of_order : order -> [> Html_types.div ] Tyxml_html.elt = <fun>
val doc_of_order : order -> Document.t = <fun>
val html_of_book :
  ?title:string -> book -> [> Html_types.div ] Tyxml_html.elt = <fun>
val doc_of_book : book -> Document.t = <fun>
val html_of_market : market -> [> Html_types.div ] Tyxml_html.elt = <fun>
val doc_of_market : market -> Document.t = <fun>

1.3 Custom type printer example

In [3]:
let leg = { leg_sec_idx = OUT1; leg_mult = 1 } in

let strat = { time_created = 0; leg1 = leg; leg2 = leg; leg3 = leg } in

let b1 = {
  b_buys = [ 
    (make BUY 100 54 1 (Outright OUT1) 1 true 1)
    ;(make BUY 100 54 2 (Outright OUT1) 1 false 1)
  ]
  ; b_sells = [
    (make SELL 100 54 3 (Outright OUT1) 1 false 1)
    ;(make SELL 100 54 4 (Outright OUT1) 1 false 1)
  ] } in

  { curr_time = 1
  ; last_ord_id = 1
  ; strat1 = strat
  ; strat2 = strat
  ; out_book1 = b1
  ; out_book2 = b1
  ; out_book3 = b1
  ; s_book1 = b1
  ; s_book2 = b1
  ; inbound_msgs = []
  ; outbound_msgs = []
  }
Out[3]:
- : market = <document>
Strategy 1
BuysSells
54 (100)
Implied
54 (100)
54 (100)
54 (100)
Strategy 2
BuysSells
54 (100)
Implied
54 (100)
54 (100)
54 (100)
Book 1
BuysSells
54 (100)
Implied
54 (100)
54 (100)
54 (100)
Book 2
BuysSells
54 (100)
Implied
54 (100)
54 (100)
54 (100)
Book 3
BuysSells
54 (100)
Implied
54 (100)
54 (100)
54 (100)

2. Outright uncrossing logic

2.1 Order book operatons (inserting, cancelling orders)

In [4]:
(* Convert fills into outbound messages *)
let rec create_fill_msgs (f : fill list) =
  match f with 
  | [] -> []
  | x::xs -> (Fill x) :: create_fill_msgs xs

(* TODO: recode this with higher-order functions *)
let rec cancel_ord_side (orders : order list) (c : cancel_ord_msg) =
  match orders with
  | [] -> []
  | x::xs ->
    begin
      if (x.o_client_id = c.co_client_id) && (x.o_id = c.co_order_id) then xs
      else x :: (cancel_ord_side xs c)
    end

(* Helper to cancel orders *)
let cancel_ord_book (co : cancel_ord_msg) (b : book) =
  match co.co_side with 
  | BUY -> { b with b_buys = (cancel_ord_side b.b_buys co) }
  | SELL -> { b with b_sells = (cancel_ord_side b.b_sells co) }

(* function used insert individual orders *)
let rec insert_order_side (orders : order list) (o : order) =
  match orders with
  | [] -> [ o ]
  | x::xs ->
    begin
      if o.o_side = BUY then
        (if o.o_price > x.o_price then o :: orders else x :: (insert_order_side xs o))
      else
        (if o.o_price < x.o_price then o :: orders else x :: (insert_order_side xs o))
    end

(* insert order into the book *)
let insert_order (o : order) (b : book) = 
  if o.o_side = BUY then
    { b with b_buys = (insert_order_side b.b_buys o) }
  else
    { b with b_sells = (insert_order_side b.b_sells o) }

(* The fills are adjusted to a single fill price during the uncross *)
let rec adjust_fill_prices (fills : fill list) ( f_price : int ) =
  match fills with 
  | [] -> []
  | x::xs -> { x with fill_price = f_price } :: ( adjust_fill_prices xs f_price )
;;
Out[4]:
val create_fill_msgs : fill list -> outbound_msg list = <fun>
val cancel_ord_side : order list -> cancel_ord_msg -> order list = <fun>
val cancel_ord_book : cancel_ord_msg -> book -> book = <fun>
val insert_order_side : order list -> order -> order list = <fun>
val insert_order : order -> book -> book = <fun>
val adjust_fill_prices : fill list -> int -> fill list = <fun>
termination proof

Termination proof

call `create_fill_msgs (List.tl f)` from `create_fill_msgs f`
originalcreate_fill_msgs f
subcreate_fill_msgs (List.tl f)
original ordinalOrdinal.Int (Ordinal.count f)
sub ordinalOrdinal.Int (Ordinal.count (List.tl f))
path[not (f = [])]
proof
detailed proof
ground_instances3
definitions0
inductions0
search_time
0.024s
details
Expand
smt_stats
num checks7
arith-assume-eqs3
arith-make-feasible89
arith-max-columns44
arith-conflicts10
rlimit count4318
mk clause95
datatype occurs check36
mk bool var191
arith-lower65
arith-diseq3
datatype splits6
decisions68
arith-propagations2
propagations82
interface eqs3
arith-bound-propagations-cheap2
arith-max-rows18
conflicts19
datatype accessor ax7
minimized lits8
arith-bound-propagations-lp2
datatype constructor ax10
num allocs1220773281
final checks12
added eqs145
del clause65
arith eq adapter49
arith-upper70
memory25.320000
max memory25.320000
Expand
  • start[0.024s]
      not (f = []) && Ordinal.count f >= 0 && Ordinal.count (List.tl f) >= 0
      ==> List.tl f = []
          || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl f)))
             (Ordinal.Int (Ordinal.count f))
  • simplify
    into
    (List.tl f = []
     || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl f)))
        (Ordinal.Int (Ordinal.count f)))
    || not
       ((not (f = []) && Ordinal.count f >= 0) && Ordinal.count (List.tl f) >= 0)
    expansions
    []
    rewrite_steps
      forward_chaining
      • unroll
        expr
        (|count_`fill list`_2248| f_2239)
        expansions
        • unroll
          expr
          (|count_`fill list`_2248| (|get.::.1_2223| f_2239))
          expansions
          • unroll
            expr
            (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`fill list`_2248|
                                                  …
            expansions
            • unsat
              (let ((a!1 (ite (>= (fill_price_118 (|get.::.0_2222| f_2239)) 0)
                              (fill_price_118 (|g…

            termination proof

            Termination proof

            call `cancel_ord_side (List.tl orders) c` from `cancel_ord_side orders c`
            originalcancel_ord_side orders c
            subcancel_ord_side (List.tl orders) c
            original ordinalOrdinal.Int (Ordinal.count orders)
            sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
            path[not ((List.hd orders).o_client_id = c.co_client_id && (List.hd orders).o_id = c.co_order_id) && not (orders = [])]
            proof
            detailed proof
            ground_instances3
            definitions0
            inductions0
            search_time
            0.017s
            details
            Expand
            smt_stats
            num checks8
            arith-assume-eqs1
            arith-make-feasible67
            arith-max-columns52
            arith-conflicts2
            rlimit count6239
            mk clause69
            datatype occurs check52
            mk bool var458
            arith-lower34
            datatype splits99
            decisions138
            propagations61
            interface eqs1
            arith-max-rows22
            conflicts9
            datatype accessor ax60
            datatype constructor ax159
            num allocs1300892877
            final checks10
            added eqs662
            del clause36
            arith eq adapter32
            arith-upper62
            memory26.190000
            max memory26.190000
            Expand
            • start[0.017s]
                not
                ((List.hd orders).o_client_id = c.co_client_id
                 && (List.hd orders).o_id = c.co_order_id)
                && not (orders = [])
                   && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                ==> not
                    (not
                     ((List.hd (List.tl orders)).o_client_id = c.co_client_id
                      && (List.hd (List.tl orders)).o_id = c.co_order_id)
                     && not (List.tl orders = []))
                    || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                       (Ordinal.Int (Ordinal.count orders))
            • simplify
              into
              (not
               (not
                ((List.hd (List.tl orders)).o_client_id = c.co_client_id
                 && (List.hd (List.tl orders)).o_id = c.co_order_id)
                && not (List.tl orders = []))
               || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                  (Ordinal.Int (Ordinal.count orders)))
              || not
                 (((not
                    ((List.hd orders).o_client_id = c.co_client_id
                     && (List.hd orders).o_id = c.co_order_id)
                    && not (orders = []))
                   && Ordinal.count orders >= 0)
                  && Ordinal.count (List.tl orders) >= 0)
              expansions
              []
              rewrite_steps
                forward_chaining
                • unroll
                  expr
                  (|count_`order list`_2273| orders_2262)
                  expansions
                  • unroll
                    expr
                    (|count_`order list`_2273| (|get.::.1_2260| orders_2262))
                    expansions
                    • unroll
                      expr
                      (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2273|
                                                           …
                      expansions
                      • unsat
                        (let ((a!1 (ite (>= (o_qty_50 (|get.::.0_2259| orders_2262)) 0)
                                        (o_qty_50 (|get.::.0…

                      termination proof

                      Termination proof

                      call `insert_order_side (List.tl orders) o` from `insert_order_side orders o`
                      originalinsert_order_side orders o
                      subinsert_order_side (List.tl orders) o
                      original ordinalOrdinal.Int (Ordinal.count orders)
                      sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                      path[not (o.o_price > (List.hd orders).o_price) && o.o_side = BUY && not (orders = [])]
                      proof
                      detailed proof
                      ground_instances3
                      definitions0
                      inductions0
                      search_time
                      0.017s
                      details
                      Expand
                      smt_stats
                      num checks8
                      arith-assume-eqs5
                      arith-make-feasible74
                      arith-max-columns59
                      arith-conflicts2
                      rlimit count12670
                      mk clause88
                      datatype occurs check64
                      mk bool var457
                      arith-lower41
                      datatype splits95
                      decisions128
                      propagations79
                      interface eqs5
                      arith-max-rows28
                      conflicts9
                      datatype accessor ax53
                      datatype constructor ax145
                      num allocs1590107134
                      final checks14
                      added eqs670
                      del clause55
                      arith eq adapter37
                      arith-upper68
                      memory16.960000
                      max memory26.190000
                      Expand
                      • start[0.017s]
                          not (o.o_price > (List.hd orders).o_price)
                          && o.o_side = BUY
                             && not (orders = [])
                                && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                          ==> not
                              (not (o.o_price > (List.hd (List.tl orders)).o_price)
                               && o.o_side = BUY && not (List.tl orders = []))
                              && not
                                 (not (o.o_price < (List.hd (List.tl orders)).o_price)
                                  && not (o.o_side = BUY) && not (List.tl orders = []))
                              || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                 (Ordinal.Int (Ordinal.count orders))
                      • simplify
                        into
                        (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                         (Ordinal.Int (Ordinal.count orders))
                         || not
                            ((o.o_price <= (List.hd (List.tl orders)).o_price && o.o_side = BUY)
                             && not (List.tl orders = []))
                            && not
                               (((List.hd (List.tl orders)).o_price <= o.o_price
                                 && not (o.o_side = BUY))
                                && not (List.tl orders = [])))
                        || not
                           ((((o.o_price <= (List.hd orders).o_price && o.o_side = BUY)
                              && not (orders = []))
                             && Ordinal.count orders >= 0)
                            && Ordinal.count (List.tl orders) >= 0)
                        expansions
                        []
                        rewrite_steps
                          forward_chaining
                          • unroll
                            expr
                            (|count_`order list`_2317| orders_2304)
                            expansions
                            • unroll
                              expr
                              (|count_`order list`_2317| (|get.::.1_2303| orders_2304))
                              expansions
                              • unroll
                                expr
                                (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2317|
                                                                     …
                                expansions
                                • unsat
                                  (let ((a!1 (ite (>= (o_time_52 (|get.::.0_2302| orders_2304)) 0)
                                                  (o_time_52 (|get.::…

                                call `insert_order_side (List.tl orders) o` from `insert_order_side orders o`
                                originalinsert_order_side orders o
                                subinsert_order_side (List.tl orders) o
                                original ordinalOrdinal.Int (Ordinal.count orders)
                                sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                path[not (o.o_price < (List.hd orders).o_price) && not (o.o_side = BUY) && not (orders = [])]
                                proof
                                detailed proof
                                ground_instances3
                                definitions0
                                inductions0
                                search_time
                                0.017s
                                details
                                Expand
                                smt_stats
                                num checks8
                                arith-make-feasible68
                                arith-max-columns54
                                arith-conflicts2
                                rlimit count6291
                                mk clause68
                                datatype occurs check52
                                mk bool var465
                                arith-lower34
                                datatype splits103
                                decisions117
                                propagations72
                                arith-max-rows23
                                conflicts10
                                datatype accessor ax58
                                datatype constructor ax156
                                num allocs1551898852
                                final checks9
                                added eqs681
                                del clause35
                                arith eq adapter32
                                arith-upper65
                                memory14.150000
                                max memory26.190000
                                Expand
                                • start[0.017s]
                                    not (o.o_price < (List.hd orders).o_price)
                                    && not (o.o_side = BUY)
                                       && not (orders = [])
                                          && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                                    ==> not
                                        (not (o.o_price > (List.hd (List.tl orders)).o_price)
                                         && o.o_side = BUY && not (List.tl orders = []))
                                        && not
                                           (not (o.o_price < (List.hd (List.tl orders)).o_price)
                                            && not (o.o_side = BUY) && not (List.tl orders = []))
                                        || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                           (Ordinal.Int (Ordinal.count orders))
                                • simplify
                                  into
                                  (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                   (Ordinal.Int (Ordinal.count orders))
                                   || not
                                      ((o.o_price <= (List.hd (List.tl orders)).o_price && o.o_side = BUY)
                                       && not (List.tl orders = []))
                                      && not
                                         (((List.hd (List.tl orders)).o_price <= o.o_price
                                           && not (o.o_side = BUY))
                                          && not (List.tl orders = [])))
                                  || not
                                     (((((List.hd orders).o_price <= o.o_price && not (o.o_side = BUY))
                                        && not (orders = []))
                                       && Ordinal.count orders >= 0)
                                      && Ordinal.count (List.tl orders) >= 0)
                                  expansions
                                  []
                                  rewrite_steps
                                    forward_chaining
                                    • unroll
                                      expr
                                      (|count_`order list`_2317| orders_2304)
                                      expansions
                                      • unroll
                                        expr
                                        (|count_`order list`_2317| (|get.::.1_2303| orders_2304))
                                        expansions
                                        • unroll
                                          expr
                                          (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2317|
                                                                               …
                                          expansions
                                          • unsat
                                            (let ((a!1 (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2317|
                                                                      …

                                          termination proof

                                          Termination proof

                                          call `adjust_fill_prices (List.tl fills) f_price` from `adjust_fill_prices fills f_price`
                                          originaladjust_fill_prices fills f_price
                                          subadjust_fill_prices (List.tl fills) f_price
                                          original ordinalOrdinal.Int (Ordinal.count fills)
                                          sub ordinalOrdinal.Int (Ordinal.count (List.tl fills))
                                          path[not (fills = [])]
                                          proof
                                          detailed proof
                                          ground_instances3
                                          definitions0
                                          inductions0
                                          search_time
                                          0.016s
                                          details
                                          Expand
                                          smt_stats
                                          num checks7
                                          arith-assume-eqs3
                                          arith-make-feasible89
                                          arith-max-columns44
                                          arith-conflicts10
                                          rlimit count4318
                                          mk clause95
                                          datatype occurs check36
                                          mk bool var191
                                          arith-lower65
                                          arith-diseq3
                                          datatype splits6
                                          decisions68
                                          arith-propagations2
                                          propagations82
                                          interface eqs3
                                          arith-bound-propagations-cheap2
                                          arith-max-rows18
                                          conflicts19
                                          datatype accessor ax7
                                          minimized lits8
                                          arith-bound-propagations-lp2
                                          datatype constructor ax10
                                          num allocs1673635519
                                          final checks12
                                          added eqs145
                                          del clause65
                                          arith eq adapter49
                                          arith-upper70
                                          memory17.560000
                                          max memory26.190000
                                          Expand
                                          • start[0.016s]
                                              not (fills = [])
                                              && Ordinal.count fills >= 0 && Ordinal.count (List.tl fills) >= 0
                                              ==> List.tl fills = []
                                                  || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl fills)))
                                                     (Ordinal.Int (Ordinal.count fills))
                                          • simplify
                                            into
                                            (List.tl fills = []
                                             || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl fills)))
                                                (Ordinal.Int (Ordinal.count fills)))
                                            || not
                                               ((not (fills = []) && Ordinal.count fills >= 0)
                                                && Ordinal.count (List.tl fills) >= 0)
                                            expansions
                                            []
                                            rewrite_steps
                                              forward_chaining
                                              • unroll
                                                expr
                                                (|count_`fill list`_2358| fills_2347)
                                                expansions
                                                • unroll
                                                  expr
                                                  (|count_`fill list`_2358| (|get.::.1_2346| fills_2347))
                                                  expansions
                                                  • unroll
                                                    expr
                                                    (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`fill list`_2358|
                                                                                          …
                                                    expansions
                                                    • unsat
                                                      (let ((a!1 (ite (>= (fill_client_id_116 (|get.::.0_2345| fills_2347)) 0)
                                                                      (fill_clien…

                                                    2.2 Book uncross

                                                    In [5]:
                                                    (* Measure for proving termination of `uncross_book` below *)
                                                    let book_measure b =
                                                      Ordinal.of_int (List.length b.b_buys + List.length b.b_sells)
                                                    
                                                    let rec uncross_book (b : book) (fills : fill list) (filled_qty : int) = 
                                                      match b.b_buys, b.b_sells with
                                                      | [], [] | _, [] | [], _ ->
                                                        (* we need to check whether there have been fills before, 
                                                          if so we need to adjust fill prices before getting out *)
                                                        begin
                                                          match fills with
                                                          | [] -> { uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty }
                                                          | x::xs ->
                                                            let fills' = x :: (adjust_fill_prices xs x.fill_price) in
                                                          { uncrossed_book = b; uncrossed_fills = fills'; uncrossed_qty = filled_qty }
                                                        end
                                                      | buy::bs, sell::ss ->
                                                        if buy.o_price >= sell.o_price then
                                                          begin
                                                            (* compute the fill qty and price *)
                                                            let fill_qty = if buy.o_qty < sell.o_qty then buy.o_qty else sell.o_qty in
                                                            let fill_price = (buy.o_price + sell.o_price) / 2 in
                                                    
                                                            (* update the orders that traded *)
                                                            let buy' = { buy with o_qty = buy.o_qty - fill_qty } in
                                                            let sell' = { sell with o_qty = sell.o_qty - fill_qty } in
                                                    
                                                            (* create the fills *)
                                                            let fill1 = { 
                                                              fill_client_id = buy.o_client_id
                                                              ; fill_qty = fill_qty
                                                              ; fill_price = fill_price
                                                              ; fill_order_id = buy.o_id
                                                              ; fill_order_done = true } in
                                                            
                                                            let fill2 = {
                                                              fill_client_id = sell.o_client_id
                                                              ; fill_qty = fill_qty
                                                              ; fill_price = fill_price
                                                              ; fill_order_id = sell.o_id
                                                              ; fill_order_done = true } in
                                                    
                                                            (* now update the books and fills *)
                                                            let new_buys = if buy'.o_qty = 0 then bs else buy'::bs in
                                                            let new_sells = if sell'.o_qty = 0 then ss else sell'::ss in
                                                            let b' = {
                                                              b_buys = new_buys
                                                              ; b_sells = new_sells } in
                                                    
                                                            (* We should not be generating fills for implied orders - there's
                                                              a different mechanism for that *)
                                                            let fills' = if not buy.o_is_implied then
                                                              fill1 :: fills else fills in
                                                            let fills' = if not sell.o_is_implied then
                                                              fill2 :: fills' else fills' in
                                                    
                                                            (* recursively go to the next level *)
                                                            uncross_book b' fills' (filled_qty + fill_qty)
                                                          end
                                                          
                                                        else
                                                          (* nothing to do here *)
                                                          { uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty }
                                                    [@@measure book_measure b]
                                                    ;;
                                                    
                                                    Out[5]:
                                                    val book_measure : book -> Ordinal.t = <fun>
                                                    val uncross_book : book -> fill list -> int -> uncross_res = <fun>
                                                    
                                                    termination proof

                                                    Termination proof

                                                    call `uncross_book {b_buys = if (List.hd b.b_buys).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty) = 0 then List.tl b.b_buys else {List.hd b.b_buys with o_qty = (List.hd b.b_buys).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)} :: (List.tl b.b_buys); b_sells = if (List.hd b.b_sells).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty) = 0 then List.tl b.b_sells else {List.hd b.b_sells with o_qty = (List.hd b.b_sells).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)} :: (List.tl b.b_sells)} (if not (List.hd b.b_sells).o_is_implied then {fill_client_id = (List.hd b.b_sells).o_client_id; fill_qty = if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty; fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2; fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true} :: (if not (List.hd b.b_buys).o_is_implied then {fill_client_id = (List.hd b.b_buys).o_client_id; fill_qty = if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty; fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2; fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true} :: fills else fills) else if not (List.hd b.b_buys).o_is_implied then {fill_client_id = (List.hd b.b_buys).o_client_id; fill_qty = if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty; fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2; fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true} :: fills else fills) (filled_qty + (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty))` from `uncross_book b fills filled_qty`
                                                    originaluncross_book b fills filled_qty
                                                    subuncross_book {b_buys = if (List.hd b.b_buys).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty) = 0 then List.tl b.b_buys else {List.hd b.b_buys with o_qty = (List.hd b.b_buys).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)} :: (List.tl b.b_buys); b_sells = if (List.hd b.b_sells).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty) = 0 then List.tl b.b_sells else {List.hd b.b_sells with o_qty = (List.hd b.b_sells).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)} :: (List.tl b.b_sells)} (if not (List.hd b.b_sells).o_is_implied then {fill_client_id = (List.hd b.b_sells).o_client_id; fill_qty = if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty; fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2; fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true} :: (if not (List.hd b.b_buys).o_is_implied then {fill_client_id = (List.hd b.b_buys).o_client_id; fill_qty = if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty; fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2; fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true} :: fills else fills) else if not (List.hd b.b_buys).o_is_implied then {fill_client_id = (List.hd b.b_buys).o_client_id; fill_qty = if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty; fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2; fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true} :: fills else fills) (filled_qty + (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty))
                                                    original ordinalbook_measure b
                                                    sub ordinalbook_measure {b_buys = if (List.hd b.b_buys).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty) = 0 then List.tl b.b_buys else {List.hd b.b_buys with o_qty = (List.hd b.b_buys).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)} :: (List.tl b.b_buys); b_sells = if (List.hd b.b_sells).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty) = 0 then List.tl b.b_sells else {List.hd b.b_sells with o_qty = (List.hd b.b_sells).o_qty - (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)} :: (List.tl b.b_sells)}
                                                    path[(List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price && not ((b.b_buys = [] && b.b_sells = [] || b.b_sells = []) || b.b_buys = [])]
                                                    proof
                                                    detailed proof
                                                    ground_instances5
                                                    definitions0
                                                    inductions0
                                                    search_time
                                                    0.033s
                                                    details
                                                    Expand
                                                    smt_stats
                                                    num checks12
                                                    arith-assume-eqs10
                                                    arith-make-feasible93
                                                    arith-max-columns41
                                                    arith-conflicts4
                                                    rlimit count14350
                                                    arith-cheap-eqs44
                                                    mk clause122
                                                    datatype occurs check164
                                                    mk bool var1131
                                                    arith-lower67
                                                    arith-diseq18
                                                    datatype splits282
                                                    decisions314
                                                    arith-propagations5
                                                    propagations224
                                                    interface eqs8
                                                    arith-bound-propagations-cheap5
                                                    arith-max-rows20
                                                    conflicts27
                                                    datatype accessor ax156
                                                    arith-bound-propagations-lp7
                                                    datatype constructor ax482
                                                    num allocs1770865146
                                                    final checks26
                                                    added eqs2245
                                                    del clause87
                                                    arith eq adapter71
                                                    arith-upper91
                                                    memory18.660000
                                                    max memory26.190000
                                                    Expand
                                                    • start[0.033s]
                                                        (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                        && not
                                                           ((b.b_buys = [] && b.b_sells = [] || b.b_sells = []) || b.b_buys = [])
                                                           && (if (List.length b.b_buys + List.length b.b_sells) >= 0
                                                               then List.length b.b_buys + List.length b.b_sells else 0)
                                                              >= 0
                                                              && (if (List.length ….b_buys + List.length ….b_sells) >= 0
                                                                  then List.length ….b_buys + List.length ….b_sells else 0)
                                                                 >= 0
                                                        ==> not
                                                            ((List.hd
                                                              (if (List.hd b.b_buys).o_qty -
                                                                  (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                   then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)
                                                                  = 0
                                                               then List.tl b.b_buys
                                                               else
                                                                 ({o_qty =
                                                                   (List.hd b.b_buys).o_qty -
                                                                   (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                    then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty);
                                                                   o_price = (List.hd b.b_buys).o_price; o_time = …; o_id = …;
                                                                   o_side = …; o_client_id = …; o_inst = …;
                                                                   o_is_implied = …}
                                                                  :: (List.tl b.b_buys)))).o_price
                                                             >=
                                                             (List.hd
                                                              (if (List.hd b.b_sells).o_qty -
                                                                  (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                   then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)
                                                                  = 0
                                                               then List.tl b.b_sells
                                                               else
                                                                 ({o_qty =
                                                                   (List.hd b.b_sells).o_qty -
                                                                   (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                    then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty);
                                                                   o_price = (List.hd b.b_sells).o_price; o_time = …; o_id = …;
                                                                   o_side = …; o_client_id = …; o_inst = …;
                                                                   o_is_implied = …}
                                                                  :: (List.tl b.b_sells)))).o_price
                                                             && not
                                                                (((if (List.hd b.b_buys).o_qty -
                                                                      (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                       then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty)
                                                                      = 0
                                                                   then List.tl b.b_buys
                                                                   else
                                                                     {o_qty =
                                                                      (List.hd b.b_buys).o_qty -
                                                                      (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                       then (List.hd b.b_buys).o_qty else (List.hd b.b_sells).o_qty);
                                                                      o_price = (List.hd b.b_buys).o_price; o_time = …;
                                                                      o_id = …; o_side = …; o_client_id = …; o_inst = …;
                                                                      o_is_implied = …}
                                                                     :: (List.tl b.b_buys))
                                                                  = []
                                                                  && (if (List.hd b.b_sells).o_qty -
                                                                         (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                          then (List.hd b.b_buys).o_qty
                                                                          else (List.hd b.b_sells).o_qty)
                                                                         = 0
                                                                      then List.tl b.b_sells
                                                                      else
                                                                        {o_qty =
                                                                         (List.hd b.b_sells).o_qty -
                                                                         (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                          then (List.hd b.b_buys).o_qty
                                                                          else (List.hd b.b_sells).o_qty);
                                                                         o_price = (List.hd b.b_sells).o_price; o_time = …;
                                                                         o_id = …; o_side = …; o_client_id = …; o_inst = …;
                                                                         o_is_implied = …}
                                                                        :: (List.tl b.b_sells))
                                                                     = []
                                                                  || (if (List.hd b.b_sells).o_qty -
                                                                         (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                          then (List.hd b.b_buys).o_qty
                                                                          else (List.hd b.b_sells).o_qty)
                                                                         = 0
                                                                      then List.tl b.b_sells
                                                                      else
                                                                        {o_qty =
                                                                         (List.hd b.b_sells).o_qty -
                                                                         (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                          then (List.hd b.b_buys).o_qty
                                                                          else (List.hd b.b_sells).o_qty);
                                                                         o_price = (List.hd b.b_sells).o_price; o_time = …;
                                                                         o_id = …; o_side = …; o_client_id = …; o_inst = …;
                                                                         o_is_implied = …}
                                                                        :: (List.tl b.b_sells))
                                                                     = [])
                                                                 || (if (List.hd b.b_buys).o_qty -
                                                                        (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                         then (List.hd b.b_buys).o_qty
                                                                         else (List.hd b.b_sells).o_qty)
                                                                        = 0
                                                                     then List.tl b.b_buys
                                                                     else
                                                                       {o_qty =
                                                                        (List.hd b.b_buys).o_qty -
                                                                        (if (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                         then (List.hd b.b_buys).o_qty
                                                                         else (List.hd b.b_sells).o_qty);
                                                                        o_price = (List.hd b.b_buys).o_price; o_time = …;
                                                                        o_id = …; o_side = …; o_client_id = …; o_inst = …;
                                                                        o_is_implied = …}
                                                                       :: (List.tl b.b_buys))
                                                                    = []))
                                                            || Ordinal.( << )
                                                               (Ordinal.Int
                                                                (if (List.length ….b_buys + List.length ….b_sells) >= 0
                                                                 then List.length ….b_buys + List.length ….b_sells else 0))
                                                               (Ordinal.Int
                                                                (if (List.length b.b_buys + List.length b.b_sells) >= 0
                                                                 then List.length b.b_buys + List.length b.b_sells else 0))
                                                    • simplify
                                                      into
                                                      (not
                                                       ((List.hd
                                                         (if (List.hd b.b_buys).o_qty
                                                             + -1
                                                               * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                  then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty)
                                                             = 0
                                                          then List.tl b.b_buys
                                                          else
                                                            ({o_qty =
                                                              (List.hd b.b_buys).o_qty
                                                              + -1
                                                                * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                   then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty);
                                                              o_price = …; o_time = …; o_id = …; o_side = …;
                                                              o_client_id = …; o_inst = …; o_is_implied = …}
                                                             :: (List.tl b.b_buys)))).o_price
                                                        >=
                                                        (List.hd
                                                         (if (List.hd b.b_sells).o_qty
                                                             + -1
                                                               * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                  then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty)
                                                             = 0
                                                          then List.tl b.b_sells
                                                          else
                                                            ({o_qty =
                                                              (List.hd b.b_sells).o_qty
                                                              + -1
                                                                * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                   then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty);
                                                              o_price = …; o_time = …; o_id = …; o_side = …;
                                                              o_client_id = …; o_inst = …; o_is_implied = …}
                                                             :: (List.tl b.b_sells)))).o_price
                                                        && not
                                                           (((if (List.hd b.b_buys).o_qty
                                                                 + -1
                                                                   * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                      then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty)
                                                                 = 0
                                                              then List.tl b.b_buys
                                                              else
                                                                {o_qty =
                                                                 (List.hd b.b_buys).o_qty
                                                                 + -1
                                                                   * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                      then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty);
                                                                 o_price = …; o_time = …; o_id = …; o_side = …;
                                                                 o_client_id = …; o_inst = …; o_is_implied = …}
                                                                :: (List.tl b.b_buys))
                                                             = []
                                                             || (if (List.hd b.b_sells).o_qty
                                                                    + -1
                                                                      * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                         then (List.hd b.b_sells).o_qty
                                                                         else (List.hd b.b_buys).o_qty)
                                                                    = 0
                                                                 then List.tl b.b_sells
                                                                 else
                                                                   {o_qty =
                                                                    (List.hd b.b_sells).o_qty
                                                                    + -1
                                                                      * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                         then (List.hd b.b_sells).o_qty
                                                                         else (List.hd b.b_buys).o_qty);
                                                                    o_price = …; o_time = …; o_id = …; o_side = …;
                                                                    o_client_id = …; o_inst = …; o_is_implied = …}
                                                                   :: (List.tl b.b_sells))
                                                                = [])
                                                            || (if (List.hd b.b_buys).o_qty
                                                                   + -1
                                                                     * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                        then (List.hd b.b_sells).o_qty
                                                                        else (List.hd b.b_buys).o_qty)
                                                                   = 0
                                                                then List.tl b.b_buys
                                                                else
                                                                  {o_qty =
                                                                   (List.hd b.b_buys).o_qty
                                                                   + -1
                                                                     * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                        then (List.hd b.b_sells).o_qty
                                                                        else (List.hd b.b_buys).o_qty);
                                                                   o_price = …; o_time = …; o_id = …; o_side = …;
                                                                   o_client_id = …; o_inst = …; o_is_implied = …}
                                                                  :: (List.tl b.b_buys))
                                                               = []
                                                               && (if (List.hd b.b_sells).o_qty
                                                                      + -1
                                                                        * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                           then (List.hd b.b_sells).o_qty
                                                                           else (List.hd b.b_buys).o_qty)
                                                                      = 0
                                                                   then List.tl b.b_sells
                                                                   else
                                                                     {o_qty =
                                                                      (List.hd b.b_sells).o_qty
                                                                      + -1
                                                                        * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                           then (List.hd b.b_sells).o_qty
                                                                           else (List.hd b.b_buys).o_qty);
                                                                      o_price = …; o_time = …; o_id = …; o_side = …;
                                                                      o_client_id = …; o_inst = …; o_is_implied = …}
                                                                     :: (List.tl b.b_sells))
                                                                  = []))
                                                       || Ordinal.( << )
                                                          (Ordinal.Int
                                                           (if (List.length
                                                                (if (List.hd b.b_buys).o_qty
                                                                    + -1
                                                                      * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                         then (List.hd b.b_sells).o_qty
                                                                         else (List.hd b.b_buys).o_qty)
                                                                    = 0
                                                                 then List.tl b.b_buys
                                                                 else
                                                                   ({o_qty =
                                                                     (List.hd b.b_buys).o_qty
                                                                     + -1
                                                                       * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                          then (List.hd b.b_sells).o_qty
                                                                          else (List.hd b.b_buys).o_qty);
                                                                     o_price = …; o_time = …; o_id = …; o_side = …;
                                                                     o_client_id = …; o_inst = …; o_is_implied = …}
                                                                    :: (List.tl b.b_buys)))
                                                                + List.length
                                                                  (if (List.hd b.b_sells).o_qty
                                                                      + -1
                                                                        * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                           then (List.hd b.b_sells).o_qty
                                                                           else (List.hd b.b_buys).o_qty)
                                                                      = 0
                                                                   then List.tl b.b_sells
                                                                   else
                                                                     ({o_qty =
                                                                       (List.hd b.b_sells).o_qty
                                                                       + -1
                                                                         * (if (List.hd b.b_sells).o_qty <=
                                                                               (List.hd b.b_buys).o_qty
                                                                            then (List.hd b.b_sells).o_qty
                                                                            else (List.hd b.b_buys).o_qty);
                                                                       o_price = …; o_time = …; o_id = …; o_side = …;
                                                                       o_client_id = …; o_inst = …; o_is_implied = …}
                                                                      :: (List.tl b.b_sells))))
                                                               >= 0
                                                            then
                                                              List.length
                                                              (if (List.hd b.b_buys).o_qty
                                                                  + -1
                                                                    * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                       then (List.hd b.b_sells).o_qty else (List.hd b.b_buys).o_qty)
                                                                  = 0
                                                               then List.tl b.b_buys
                                                               else
                                                                 ({o_qty =
                                                                   (List.hd b.b_buys).o_qty
                                                                   + -1
                                                                     * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                        then (List.hd b.b_sells).o_qty
                                                                        else (List.hd b.b_buys).o_qty);
                                                                   o_price = …; o_time = …; o_id = …; o_side = …;
                                                                   o_client_id = …; o_inst = …; o_is_implied = …}
                                                                  :: (List.tl b.b_buys)))
                                                              + List.length
                                                                (if (List.hd b.b_sells).o_qty
                                                                    + -1
                                                                      * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                         then (List.hd b.b_sells).o_qty
                                                                         else (List.hd b.b_buys).o_qty)
                                                                    = 0
                                                                 then List.tl b.b_sells
                                                                 else
                                                                   ({o_qty =
                                                                     (List.hd b.b_sells).o_qty
                                                                     + -1
                                                                       * (if (List.hd b.b_sells).o_qty <= (List.hd b.b_buys).o_qty
                                                                          then (List.hd b.b_sells).o_qty
                                                                          else (List.hd b.b_buys).o_qty);
                                                                     o_price = …; o_time = …; o_id = …; o_side = …;
                                                                     o_client_id = …; o_inst = …; o_is_implied = …}
                                                                    :: (List.tl b.b_sells)))
                                                            else 0))
                                                          (Ordinal.Int
                                                           (if (List.length b.b_buys + List.length b.b_sells) >= 0
                                                            then List.length b.b_buys + List.length b.b_sells else 0)))
                                                      || not
                                                         (… >= …
                                                          && not
                                                             ((b.b_buys = [] || b.b_sells = []) || b.b_buys = [] && b.b_sells = []))
                                                      expansions
                                                      []
                                                      rewrite_steps
                                                        forward_chaining
                                                        • unroll
                                                          expr
                                                          (|List.length_2390| (b_sells_69 b_2401))
                                                          expansions
                                                          • unroll
                                                            expr
                                                            (|List.length_2390| (b_buys_68 b_2401))
                                                            expansions
                                                            • unroll
                                                              expr
                                                              (let ((a!1 (<= (o_qty_50 (|get.::.0_2384| (b_sells_69 b_2401)))
                                                                             (o_qty_50 (|get.::.0_…
                                                              expansions
                                                              • unroll
                                                                expr
                                                                (let ((a!1 (<= (o_qty_50 (|get.::.0_2384| (b_sells_69 b_2401)))
                                                                               (o_qty_50 (|get.::.0_…
                                                                expansions
                                                                • unroll
                                                                  expr
                                                                  (let ((a!1 (<= (o_qty_50 (|get.::.0_2384| (b_sells_69 b_2401)))
                                                                                 (o_qty_50 (|get.::.0_…
                                                                  expansions
                                                                  • unsat
                                                                    (let ((a!1 (* (- 1) (o_qty_50 (|get.::.0_2384| (b_sells_69 b_2401)))))
                                                                          (a!10 (* (- 1) (|List.l…

                                                                  We now have a function that does something real - uncross_book (b : book) (fills : fill list) (filled_qty : int). Let's experiment how it works with some concrete values.

                                                                  In [6]:
                                                                  let book1 = {
                                                                    b_buys = [
                                                                      (make BUY 100 55 1 (Outright OUT1) 1 false 1)
                                                                      ; (make BUY 100 50 2 (Outright OUT1) 1 false 1)
                                                                      ]
                                                                   ; b_sells = [
                                                                      (make BUY 100 54 3 (Outright OUT1) 1 false 1)
                                                                      ; (make BUY 100 54 4 (Outright OUT1) 1 false 1)
                                                                    ]
                                                                  } in
                                                                  
                                                                  uncross_book book1 [] 0
                                                                  
                                                                  Out[6]:
                                                                  - : uncross_res =
                                                                  {uncrossed_book = <document>;
                                                                   uncrossed_fills =
                                                                    [{fill_client_id = 1; fill_qty = 100; fill_price = 54; fill_order_id = 3;
                                                                      fill_order_done = true};
                                                                     {fill_client_id = 1; fill_qty = 100; fill_price = 54; fill_order_id = 1;
                                                                      fill_order_done = true}];
                                                                   uncrossed_qty = 100}
                                                                  
                                                                  M1 Mar21
                                                                  BuysSells
                                                                  50 (100)
                                                                  54 (100)

                                                                  2.3 A few verification goals

                                                                  Let's try to verify some verification goals.

                                                                  The first one will make sure that for an order book that is sorted (so the best bid/ask orders will be the first ones in their respective lists. Note: this is not based on the 'imbalance' of the order book, this is simply taking the midpointt of the most aggressive orders.

                                                                  In [7]:
                                                                  (* Returns true if the orders are sorted with respect to price *)
                                                                  let rec side_price_sorted (si : side) (orders : order list) =
                                                                    match orders with
                                                                    | [] -> true
                                                                    | x::[] -> true
                                                                    | x::y::xs ->
                                                                      if si = BUY then
                                                                        begin
                                                                          if y.o_price > x.o_price && x.o_price > 0 then false else (side_price_sorted si (y::xs))
                                                                        end
                                                                      else
                                                                        begin
                                                                          if y.o_price < x.o_price && y.o_price > 0 then false else (side_price_sorted si (y::xs))
                                                                        end
                                                                  ;;
                                                                  
                                                                  (* Let's make sure all the fills have this price *)
                                                                  let rec fills_good_price (fills : fill list) (p : int) = 
                                                                    match fills with
                                                                    | [] -> true
                                                                    | x::xs -> (x.fill_price = p) && (fills_good_price xs p)
                                                                  ;;
                                                                  
                                                                  (** Let's to verify some properties *)
                                                                  let fill_price_midpoint (b : book) =
                                                                  
                                                                    let buys_sorted = side_price_sorted BUY b.b_buys in
                                                                    let sells_sorted = side_price_sorted SELL b.b_sells in
                                                                  
                                                                    let result_good = 
                                                                      begin
                                                                        match b.b_buys, b.b_sells with
                                                                        | [], _ -> true
                                                                        | _, [] -> true
                                                                        | x::xs, y::ys ->
                                                                          let unc_res = uncross_book b [] 0 in
                                                                          if x.o_price >= y.o_price then
                                                                            let midprice = (x.o_price + y.o_price) / 2 in
                                                                            (List.length unc_res.uncrossed_fills) > 0 && (fills_good_price unc_res.uncrossed_fills midprice)
                                                                          else
                                                                            true
                                                                      end in
                                                                  
                                                                    (* This is the 'punchline'... if the sides are price-sorted, then the fills will be the first midpoint *)
                                                                    (buys_sorted && sells_sorted) ==> result_good
                                                                  ;;
                                                                  
                                                                  
                                                                  verify fill_price_midpoint
                                                                  
                                                                  Out[7]:
                                                                  val side_price_sorted : side -> order list -> bool = <fun>
                                                                  val fills_good_price : fill list -> int -> bool = <fun>
                                                                  val fill_price_midpoint : book -> bool = <fun>
                                                                  - : book -> bool = <fun>
                                                                  module CX : sig val b : book end
                                                                  
                                                                  termination proof

                                                                  Termination proof

                                                                  call `side_price_sorted si (List.tl orders)` from `side_price_sorted si orders`
                                                                  originalside_price_sorted si orders
                                                                  subside_price_sorted si (List.tl orders)
                                                                  original ordinalOrdinal.Int (Ordinal.count orders)
                                                                  sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                                                  path[not ((List.hd (List.tl orders)).o_price > (List.hd orders).o_price && (List.hd orders).o_price > 0) && si = BUY && not (orders <> [] && List.tl orders = []) && not (orders = [])]
                                                                  proof
                                                                  detailed proof
                                                                  ground_instances3
                                                                  definitions0
                                                                  inductions0
                                                                  search_time
                                                                  0.028s
                                                                  details
                                                                  Expand
                                                                  smt_stats
                                                                  num checks8
                                                                  arith-make-feasible86
                                                                  arith-max-columns54
                                                                  arith-conflicts2
                                                                  rlimit count14965
                                                                  arith-cheap-eqs1
                                                                  mk clause82
                                                                  datatype occurs check55
                                                                  mk bool var518
                                                                  arith-lower52
                                                                  datatype splits111
                                                                  decisions164
                                                                  arith-propagations1
                                                                  propagations88
                                                                  arith-bound-propagations-cheap1
                                                                  arith-max-rows23
                                                                  conflicts11
                                                                  datatype accessor ax61
                                                                  minimized lits3
                                                                  arith-bound-propagations-lp3
                                                                  datatype constructor ax185
                                                                  num allocs1931349858
                                                                  final checks10
                                                                  added eqs795
                                                                  del clause40
                                                                  arith eq adapter36
                                                                  arith-upper74
                                                                  memory22.690000
                                                                  max memory26.190000
                                                                  Expand
                                                                  • start[0.028s]
                                                                      not
                                                                      ((List.hd (List.tl orders)).o_price > (List.hd orders).o_price
                                                                       && (List.hd orders).o_price > 0)
                                                                      && si = BUY
                                                                         && not (orders <> [] && List.tl orders = [])
                                                                            && not (orders = [])
                                                                               && Ordinal.count orders >= 0
                                                                                  && Ordinal.count (List.tl orders) >= 0
                                                                      ==> not
                                                                          (not
                                                                           ((List.hd (List.tl (List.tl orders))).o_price >
                                                                            (List.hd (List.tl orders)).o_price
                                                                            && (List.hd (List.tl orders)).o_price > 0)
                                                                           && si = BUY
                                                                              && not ((List.tl orders) <> [] && List.tl (List.tl orders) = [])
                                                                                 && not (List.tl orders = []))
                                                                          && not
                                                                             (not
                                                                              ((List.hd (List.tl (List.tl orders))).o_price <
                                                                               (List.hd (List.tl orders)).o_price
                                                                               && (List.hd (List.tl (List.tl orders))).o_price > 0)
                                                                              && not (si = BUY)
                                                                                 && not ((List.tl orders) <> [] && List.tl (List.tl orders) = [])
                                                                                    && not (List.tl orders = []))
                                                                          || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                             (Ordinal.Int (Ordinal.count orders))
                                                                  • simplify
                                                                    into
                                                                    (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                     (Ordinal.Int (Ordinal.count orders))
                                                                     || not
                                                                        (((not
                                                                           (not
                                                                            ((List.hd (List.tl (List.tl orders))).o_price <=
                                                                             (List.hd (List.tl orders)).o_price)
                                                                            && not ((List.hd (List.tl orders)).o_price <= 0))
                                                                           && si = BUY)
                                                                          && not ((List.tl orders) <> [] && List.tl (List.tl orders) = []))
                                                                         && not (List.tl orders = []))
                                                                        && not
                                                                           (((not
                                                                              (not
                                                                               ((List.hd (List.tl orders)).o_price <=
                                                                                (List.hd (List.tl (List.tl orders))).o_price)
                                                                               && not ((List.hd (List.tl (List.tl orders))).o_price <= 0))
                                                                              && not (si = BUY))
                                                                             && not ((List.tl orders) <> [] && List.tl (List.tl orders) = []))
                                                                            && not (List.tl orders = [])))
                                                                    || not
                                                                       (((((not
                                                                            (not ((List.hd (List.tl orders)).o_price <= (List.hd orders).o_price)
                                                                             && not ((List.hd orders).o_price <= 0))
                                                                            && si = BUY)
                                                                           && not (orders <> [] && List.tl orders = []))
                                                                          && not (orders = []))
                                                                         && Ordinal.count orders >= 0)
                                                                        && Ordinal.count (List.tl orders) >= 0)
                                                                    expansions
                                                                    []
                                                                    rewrite_steps
                                                                      forward_chaining
                                                                      • unroll
                                                                        expr
                                                                        (|count_`order list`_2535| orders_2523)
                                                                        expansions
                                                                        • unroll
                                                                          expr
                                                                          (|count_`order list`_2535| (|get.::.1_2521| orders_2523))
                                                                          expansions
                                                                          • unroll
                                                                            expr
                                                                            (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2535|
                                                                                                                 …
                                                                            expansions
                                                                            • unsat
                                                                              (let ((a!1 (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2535|
                                                                                                        …

                                                                            call `side_price_sorted si (List.tl orders)` from `side_price_sorted si orders`
                                                                            originalside_price_sorted si orders
                                                                            subside_price_sorted si (List.tl orders)
                                                                            original ordinalOrdinal.Int (Ordinal.count orders)
                                                                            sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                                                            path[not ((List.hd (List.tl orders)).o_price < (List.hd orders).o_price && (List.hd (List.tl orders)).o_price > 0) && not (si = BUY) && not (orders <> [] && List.tl orders = []) && not (orders = [])]
                                                                            proof
                                                                            detailed proof
                                                                            ground_instances3
                                                                            definitions0
                                                                            inductions0
                                                                            search_time
                                                                            0.027s
                                                                            details
                                                                            Expand
                                                                            smt_stats
                                                                            num checks8
                                                                            arith-assume-eqs5
                                                                            arith-make-feasible98
                                                                            arith-max-columns58
                                                                            arith-conflicts2
                                                                            rlimit count7434
                                                                            arith-cheap-eqs2
                                                                            mk clause98
                                                                            datatype occurs check70
                                                                            mk bool var503
                                                                            arith-lower56
                                                                            datatype splits101
                                                                            decisions158
                                                                            arith-propagations1
                                                                            propagations99
                                                                            interface eqs5
                                                                            arith-bound-propagations-cheap1
                                                                            arith-max-rows27
                                                                            conflicts12
                                                                            datatype accessor ax57
                                                                            minimized lits3
                                                                            datatype constructor ax165
                                                                            num allocs1842427128
                                                                            final checks14
                                                                            added eqs721
                                                                            del clause60
                                                                            arith eq adapter43
                                                                            arith-upper83
                                                                            memory22.820000
                                                                            max memory26.190000
                                                                            Expand
                                                                            • start[0.027s]
                                                                                not
                                                                                ((List.hd (List.tl orders)).o_price < (List.hd orders).o_price
                                                                                 && (List.hd (List.tl orders)).o_price > 0)
                                                                                && not (si = BUY)
                                                                                   && not (orders <> [] && List.tl orders = [])
                                                                                      && not (orders = [])
                                                                                         && Ordinal.count orders >= 0
                                                                                            && Ordinal.count (List.tl orders) >= 0
                                                                                ==> not
                                                                                    (not
                                                                                     ((List.hd (List.tl (List.tl orders))).o_price >
                                                                                      (List.hd (List.tl orders)).o_price
                                                                                      && (List.hd (List.tl orders)).o_price > 0)
                                                                                     && si = BUY
                                                                                        && not ((List.tl orders) <> [] && List.tl (List.tl orders) = [])
                                                                                           && not (List.tl orders = []))
                                                                                    && not
                                                                                       (not
                                                                                        ((List.hd (List.tl (List.tl orders))).o_price <
                                                                                         (List.hd (List.tl orders)).o_price
                                                                                         && (List.hd (List.tl (List.tl orders))).o_price > 0)
                                                                                        && not (si = BUY)
                                                                                           && not ((List.tl orders) <> [] && List.tl (List.tl orders) = [])
                                                                                              && not (List.tl orders = []))
                                                                                    || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                       (Ordinal.Int (Ordinal.count orders))
                                                                            • simplify
                                                                              into
                                                                              (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                               (Ordinal.Int (Ordinal.count orders))
                                                                               || not
                                                                                  (((not
                                                                                     (not
                                                                                      ((List.hd (List.tl (List.tl orders))).o_price <=
                                                                                       (List.hd (List.tl orders)).o_price)
                                                                                      && not ((List.hd (List.tl orders)).o_price <= 0))
                                                                                     && si = BUY)
                                                                                    && not ((List.tl orders) <> [] && List.tl (List.tl orders) = []))
                                                                                   && not (List.tl orders = []))
                                                                                  && not
                                                                                     (((not
                                                                                        (not
                                                                                         ((List.hd (List.tl orders)).o_price <=
                                                                                          (List.hd (List.tl (List.tl orders))).o_price)
                                                                                         && not ((List.hd (List.tl (List.tl orders))).o_price <= 0))
                                                                                        && not (si = BUY))
                                                                                       && not ((List.tl orders) <> [] && List.tl (List.tl orders) = []))
                                                                                      && not (List.tl orders = [])))
                                                                              || not
                                                                                 (((((not
                                                                                      (not ((List.hd orders).o_price <= (List.hd (List.tl orders)).o_price)
                                                                                       && not ((List.hd (List.tl orders)).o_price <= 0))
                                                                                      && not (si = BUY))
                                                                                     && not (orders <> [] && List.tl orders = []))
                                                                                    && not (orders = []))
                                                                                   && Ordinal.count orders >= 0)
                                                                                  && Ordinal.count (List.tl orders) >= 0)
                                                                              expansions
                                                                              []
                                                                              rewrite_steps
                                                                                forward_chaining
                                                                                • unroll
                                                                                  expr
                                                                                  (|count_`order list`_2535| orders_2523)
                                                                                  expansions
                                                                                  • unroll
                                                                                    expr
                                                                                    (|count_`order list`_2535| (|get.::.1_2521| orders_2523))
                                                                                    expansions
                                                                                    • unroll
                                                                                      expr
                                                                                      (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2535|
                                                                                                                           …
                                                                                      expansions
                                                                                      • unsat
                                                                                        (let ((a!1 (ite (>= (o_price_51 (|get.::.0_2520| orders_2523)) 0)
                                                                                                        (o_price_51 (|get.…

                                                                                      termination proof

                                                                                      Termination proof

                                                                                      call `fills_good_price (List.tl fills) p` from `fills_good_price fills p`
                                                                                      originalfills_good_price fills p
                                                                                      subfills_good_price (List.tl fills) p
                                                                                      original ordinalOrdinal.Int (Ordinal.count fills)
                                                                                      sub ordinalOrdinal.Int (Ordinal.count (List.tl fills))
                                                                                      path[(List.hd fills).fill_price = p && not (fills = [])]
                                                                                      proof
                                                                                      detailed proof
                                                                                      ground_instances3
                                                                                      definitions0
                                                                                      inductions0
                                                                                      search_time
                                                                                      0.017s
                                                                                      details
                                                                                      Expand
                                                                                      smt_stats
                                                                                      num checks8
                                                                                      arith-assume-eqs2
                                                                                      arith-make-feasible59
                                                                                      arith-max-columns44
                                                                                      arith-conflicts2
                                                                                      rlimit count3995
                                                                                      mk clause62
                                                                                      datatype occurs check44
                                                                                      mk bool var154
                                                                                      arith-lower32
                                                                                      datatype splits8
                                                                                      decisions56
                                                                                      propagations62
                                                                                      interface eqs2
                                                                                      arith-max-rows20
                                                                                      conflicts11
                                                                                      datatype accessor ax7
                                                                                      datatype constructor ax10
                                                                                      num allocs1989196776
                                                                                      final checks11
                                                                                      added eqs126
                                                                                      del clause37
                                                                                      arith eq adapter30
                                                                                      arith-upper54
                                                                                      memory25.950000
                                                                                      max memory26.190000
                                                                                      Expand
                                                                                      • start[0.017s]
                                                                                          (List.hd fills).fill_price = p
                                                                                          && not (fills = [])
                                                                                             && Ordinal.count fills >= 0 && Ordinal.count (List.tl fills) >= 0
                                                                                          ==> not
                                                                                              ((List.hd (List.tl fills)).fill_price = p && not (List.tl fills = []))
                                                                                              || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl fills)))
                                                                                                 (Ordinal.Int (Ordinal.count fills))
                                                                                      • simplify
                                                                                        into
                                                                                        (not ((List.hd (List.tl fills)).fill_price = p && not (List.tl fills = []))
                                                                                         || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl fills)))
                                                                                            (Ordinal.Int (Ordinal.count fills)))
                                                                                        || not
                                                                                           ((((List.hd fills).fill_price = p && not (fills = []))
                                                                                             && Ordinal.count fills >= 0)
                                                                                            && Ordinal.count (List.tl fills) >= 0)
                                                                                        expansions
                                                                                        []
                                                                                        rewrite_steps
                                                                                          forward_chaining
                                                                                          • unroll
                                                                                            expr
                                                                                            (|count_`fill list`_2567| fills_2556)
                                                                                            expansions
                                                                                            • unroll
                                                                                              expr
                                                                                              (|count_`fill list`_2567| (|get.::.1_2555| fills_2556))
                                                                                              expansions
                                                                                              • unroll
                                                                                                expr
                                                                                                (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`fill list`_2567|
                                                                                                                                      …
                                                                                                expansions
                                                                                                • unsat
                                                                                                  (let ((a!1 (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`fill list`_2567|
                                                                                                                             …

                                                                                                Counterexample (after 6 steps, 0.033s):
                                                                                                 let (b : book) =
                                                                                                   {b_buys =
                                                                                                     [{o_qty = 45162; o_price = (-92214); o_time = 3; o_id = 4; o_side = BUY;
                                                                                                       o_client_id = 5; o_inst = (Strategy (STRAT1)); o_is_implied = true}];
                                                                                                    b_sells =
                                                                                                     [{o_qty = 45163; o_price = (-92214); o_time = 21; o_id = 13;
                                                                                                       o_side = BUY; o_client_id = 14; o_inst = (Strategy (STRAT1));
                                                                                                       o_is_implied = true}]}
                                                                                                
                                                                                                Refuted
                                                                                                proof attempt
                                                                                                ground_instances6
                                                                                                definitions0
                                                                                                inductions0
                                                                                                search_time
                                                                                                0.033s
                                                                                                details
                                                                                                Expand
                                                                                                smt_stats
                                                                                                num checks13
                                                                                                arith-assume-eqs24
                                                                                                arith-make-feasible105
                                                                                                arith-max-columns51
                                                                                                arith-conflicts1
                                                                                                rlimit count17569
                                                                                                arith-gcd-calls1
                                                                                                arith-cheap-eqs97
                                                                                                mk clause299
                                                                                                datatype occurs check320
                                                                                                mk bool var1339
                                                                                                arith-lower94
                                                                                                arith-diseq17
                                                                                                datatype splits295
                                                                                                decisions427
                                                                                                arith-propagations9
                                                                                                propagations332
                                                                                                arith-patches1
                                                                                                interface eqs23
                                                                                                arith-bound-propagations-cheap9
                                                                                                arith-max-rows28
                                                                                                conflicts19
                                                                                                datatype accessor ax160
                                                                                                arith-bound-propagations-lp5
                                                                                                datatype constructor ax480
                                                                                                num allocs2057825584
                                                                                                final checks48
                                                                                                added eqs2489
                                                                                                del clause130
                                                                                                arith eq adapter67
                                                                                                arith-upper87
                                                                                                arith-branch1
                                                                                                memory29.810000
                                                                                                max memory29.810000
                                                                                                Expand
                                                                                                • start[0.033s]
                                                                                                    side_price_sorted BUY :var_0:.b_buys
                                                                                                    && side_price_sorted SELL :var_0:.b_sells
                                                                                                    ==> (if :var_0:.b_buys = [] then true
                                                                                                         else
                                                                                                         if :var_0:.b_sells = [] then true
                                                                                                         else
                                                                                                         if (List.hd :var_0:.b_buys).o_price >=
                                                                                                            (List.hd :var_0:.b_sells).o_price
                                                                                                         then List.length … > 0 && fills_good_price … … else true)
                                                                                                • simplify

                                                                                                  into
                                                                                                  (((:var_0:.b_sells = [] || :var_0:.b_buys = [])
                                                                                                    || not (List.length (uncross_book :var_0: [] 0).uncrossed_fills <= 0)
                                                                                                       && fills_good_price (uncross_book :var_0: [] 0).uncrossed_fills
                                                                                                          (((List.hd :var_0:.b_buys).o_price
                                                                                                            + (List.hd :var_0:.b_sells).o_price)
                                                                                                           / 2))
                                                                                                   || not
                                                                                                      ((List.hd :var_0:.b_buys).o_price >= (List.hd :var_0:.b_sells).o_price))
                                                                                                  || not
                                                                                                     (side_price_sorted BUY :var_0:.b_buys
                                                                                                      && side_price_sorted SELL :var_0:.b_sells)
                                                                                                  expansions
                                                                                                  []
                                                                                                  rewrite_steps
                                                                                                    forward_chaining
                                                                                                    • unroll
                                                                                                      expr
                                                                                                      (side_price_sorted_191 SELL_16 (b_sells_69 b_215))
                                                                                                      expansions
                                                                                                      • unroll
                                                                                                        expr
                                                                                                        (side_price_sorted_191 BUY_15 (b_buys_68 b_215))
                                                                                                        expansions
                                                                                                        • unroll
                                                                                                          expr
                                                                                                          (let ((a!1 (+ (o_price_51 (|get.::.0_2594| (b_buys_68 b_215)))
                                                                                                                        (o_price_51 (|get.::.0_…
                                                                                                          expansions
                                                                                                          • unroll
                                                                                                            expr
                                                                                                            (uncross_book_168 b_215 |[]_2| 0)
                                                                                                            expansions
                                                                                                            • unroll
                                                                                                              expr
                                                                                                              (|List.length_2601| (uncrossed_fills_123 (uncross_book_168 b_215 |[]_2| 0)))
                                                                                                              expansions
                                                                                                              • unroll
                                                                                                                expr
                                                                                                                (let ((a!1 (<= (o_qty_50 (|get.::.0_2594| (b_sells_69 b_215)))
                                                                                                                               (o_qty_50 (|get.::.0_2…
                                                                                                                expansions
                                                                                                                • Sat (Some let (b : book) = {b_buys = [{o_qty = 45162; o_price = (-92214); o_time = 3; o_id = 4; o_side = BUY; o_client_id = 5; o_inst = (Strategy (STRAT1)); o_is_implied = true}]; b_sells = [{o_qty = 45163; o_price = (-92214); o_time = 21; o_id = 13; o_side = BUY; o_client_id = 14; o_inst = (Strategy (STRAT1)); o_is_implied = true}]} )

                                                                                                                Our second verification goal will look to make sure that no quantities are lost during uncrossing. Note that no fills are generated for implied orders (there's a different mechanism for that), so when we look at the book we will only consider outright orders. Note that o_qty represents the residual order quantity - for this demo, we do not differentiate between original, filled and residual order quantity. When order is created, the qty is set to that number and is decreased when filled.

                                                                                                                In [8]:
                                                                                                                (* All no quantities get lost during uncross *)
                                                                                                                let no_lost_qtys (b : book) = 
                                                                                                                  
                                                                                                                  let rec qtys_pos_nonimp = function
                                                                                                                    | [] -> true
                                                                                                                    | x::xs -> x.o_qty >= 0 && not x.o_is_implied && (qtys_pos_nonimp xs) in
                                                                                                                
                                                                                                                  let rec sum_qtys = function
                                                                                                                    | [] -> 0
                                                                                                                    | x::xs -> x.o_qty + (sum_qtys xs) in
                                                                                                                
                                                                                                                  let rec sum_fill_qtys = function
                                                                                                                    | [] -> 0
                                                                                                                    | x::xs -> x.fill_qty + (sum_fill_qtys xs) in
                                                                                                                
                                                                                                                  let unc_res = uncross_book b [] 0 in
                                                                                                                  
                                                                                                                  (* We need to make sure the book is non-negative *)
                                                                                                                  let book_nonneg_nonimp = (qtys_pos_nonimp b.b_buys) && (qtys_pos_nonimp b.b_sells) in
                                                                                                                
                                                                                                                  (* Let's sum up all of the quantities of orders before the uncross *)
                                                                                                                  let count_before = (sum_qtys b.b_buys) + (sum_qtys b.b_sells) in
                                                                                                                  
                                                                                                                  (* And after *)
                                                                                                                  let count_after = (sum_qtys unc_res.uncrossed_book.b_buys) + 
                                                                                                                                    (sum_qtys unc_res.uncrossed_book.b_sells) +
                                                                                                                                    (sum_fill_qtys unc_res.uncrossed_fills) in
                                                                                                                
                                                                                                                  book_nonneg_nonimp ==> (count_before = count_after)
                                                                                                                ;;
                                                                                                                
                                                                                                                verify ~upto:15 no_lost_qtys
                                                                                                                
                                                                                                                Out[8]:
                                                                                                                val no_lost_qtys : book -> bool = <fun>
                                                                                                                - : book -> bool = <fun>
                                                                                                                
                                                                                                                termination proof

                                                                                                                Termination proof

                                                                                                                call `recfun.no_lost_qtys.qtys_pos_nonimp.0 (List.tl _x)` from `recfun.no_lost_qtys.qtys_pos_nonimp.0 _x`
                                                                                                                originalrecfun.no_lost_qtys.qtys_pos_nonimp.0 _x
                                                                                                                subrecfun.no_lost_qtys.qtys_pos_nonimp.0 (List.tl _x)
                                                                                                                original ordinalOrdinal.Int (Ordinal.count _x)
                                                                                                                sub ordinalOrdinal.Int (Ordinal.count (List.tl _x))
                                                                                                                path[not (List.hd _x).o_is_implied && (List.hd _x).o_qty >= 0 && not (_x = [])]
                                                                                                                proof
                                                                                                                detailed proof
                                                                                                                ground_instances3
                                                                                                                definitions0
                                                                                                                inductions0
                                                                                                                search_time
                                                                                                                0.060s
                                                                                                                details
                                                                                                                Expand
                                                                                                                smt_stats
                                                                                                                num checks8
                                                                                                                arith-assume-eqs4
                                                                                                                arith-make-feasible64
                                                                                                                arith-max-columns51
                                                                                                                arith-conflicts2
                                                                                                                rlimit count5222
                                                                                                                mk clause71
                                                                                                                datatype occurs check49
                                                                                                                mk bool var346
                                                                                                                arith-lower33
                                                                                                                datatype splits63
                                                                                                                decisions83
                                                                                                                propagations51
                                                                                                                interface eqs4
                                                                                                                arith-max-rows23
                                                                                                                conflicts9
                                                                                                                datatype accessor ax44
                                                                                                                datatype constructor ax110
                                                                                                                num allocs2115031205
                                                                                                                final checks13
                                                                                                                added eqs452
                                                                                                                del clause48
                                                                                                                arith eq adapter31
                                                                                                                arith-upper59
                                                                                                                memory32.900000
                                                                                                                max memory32.900000
                                                                                                                Expand
                                                                                                                • start[0.060s]
                                                                                                                    not (List.hd _x).o_is_implied
                                                                                                                    && (List.hd _x).o_qty >= 0
                                                                                                                       && not (_x = [])
                                                                                                                          && Ordinal.count _x >= 0 && Ordinal.count (List.tl _x) >= 0
                                                                                                                    ==> not
                                                                                                                        (not (List.hd (List.tl _x)).o_is_implied
                                                                                                                         && (List.hd (List.tl _x)).o_qty >= 0 && not (List.tl _x = []))
                                                                                                                        || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl _x)))
                                                                                                                           (Ordinal.Int (Ordinal.count _x))
                                                                                                                • simplify
                                                                                                                  into
                                                                                                                  (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl _x)))
                                                                                                                   (Ordinal.Int (Ordinal.count _x))
                                                                                                                   || not
                                                                                                                      ((not (List.hd (List.tl _x)).o_is_implied
                                                                                                                        && (List.hd (List.tl _x)).o_qty >= 0)
                                                                                                                       && not (List.tl _x = [])))
                                                                                                                  || not
                                                                                                                     ((((not (List.hd _x).o_is_implied && (List.hd _x).o_qty >= 0)
                                                                                                                        && not (_x = []))
                                                                                                                       && Ordinal.count _x >= 0)
                                                                                                                      && Ordinal.count (List.tl _x) >= 0)
                                                                                                                  expansions
                                                                                                                  []
                                                                                                                  rewrite_steps
                                                                                                                    forward_chaining
                                                                                                                    • unroll
                                                                                                                      expr
                                                                                                                      (|count_`order list`_2688| _x_2679)
                                                                                                                      expansions
                                                                                                                      • unroll
                                                                                                                        expr
                                                                                                                        (|count_`order list`_2688| (|get.::.1_2678| _x_2679))
                                                                                                                        expansions
                                                                                                                        • unroll
                                                                                                                          expr
                                                                                                                          (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2688|
                                                                                                                                                               …
                                                                                                                          expansions
                                                                                                                          • unsat
                                                                                                                            (let ((a!1 (ite (>= (o_price_51 (|get.::.0_2677| _x_2679)) 0)
                                                                                                                                            (o_price_51 (|get.::.0…

                                                                                                                          termination proof

                                                                                                                          Termination proof

                                                                                                                          call `recfun.no_lost_qtys.sum_qtys.1 (List.tl _x)` from `recfun.no_lost_qtys.sum_qtys.1 _x`
                                                                                                                          originalrecfun.no_lost_qtys.sum_qtys.1 _x
                                                                                                                          subrecfun.no_lost_qtys.sum_qtys.1 (List.tl _x)
                                                                                                                          original ordinalOrdinal.Int (Ordinal.count _x)
                                                                                                                          sub ordinalOrdinal.Int (Ordinal.count (List.tl _x))
                                                                                                                          path[not (_x = [])]
                                                                                                                          proof
                                                                                                                          detailed proof
                                                                                                                          ground_instances3
                                                                                                                          definitions0
                                                                                                                          inductions0
                                                                                                                          search_time
                                                                                                                          0.017s
                                                                                                                          details
                                                                                                                          Expand
                                                                                                                          smt_stats
                                                                                                                          num checks8
                                                                                                                          arith-assume-eqs1
                                                                                                                          arith-make-feasible94
                                                                                                                          arith-max-columns46
                                                                                                                          arith-conflicts9
                                                                                                                          rlimit count10601
                                                                                                                          mk clause94
                                                                                                                          datatype occurs check46
                                                                                                                          mk bool var329
                                                                                                                          arith-lower73
                                                                                                                          arith-diseq4
                                                                                                                          datatype splits46
                                                                                                                          decisions92
                                                                                                                          arith-propagations2
                                                                                                                          propagations90
                                                                                                                          interface eqs1
                                                                                                                          arith-bound-propagations-cheap2
                                                                                                                          arith-max-rows16
                                                                                                                          conflicts22
                                                                                                                          datatype accessor ax33
                                                                                                                          minimized lits8
                                                                                                                          arith-bound-propagations-lp7
                                                                                                                          datatype constructor ax75
                                                                                                                          num allocs2220061063
                                                                                                                          final checks10
                                                                                                                          added eqs384
                                                                                                                          del clause49
                                                                                                                          arith eq adapter54
                                                                                                                          arith-upper68
                                                                                                                          memory33.230000
                                                                                                                          max memory33.230000
                                                                                                                          Expand
                                                                                                                          • start[0.017s]
                                                                                                                              not (_x = []) && Ordinal.count _x >= 0 && Ordinal.count (List.tl _x) >= 0
                                                                                                                              ==> List.tl _x = []
                                                                                                                                  || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl _x)))
                                                                                                                                     (Ordinal.Int (Ordinal.count _x))
                                                                                                                          • simplify
                                                                                                                            into
                                                                                                                            (not
                                                                                                                             ((not (_x = []) && Ordinal.count _x >= 0) && Ordinal.count (List.tl _x) >= 0)
                                                                                                                             || List.tl _x = [])
                                                                                                                            || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl _x)))
                                                                                                                               (Ordinal.Int (Ordinal.count _x))
                                                                                                                            expansions
                                                                                                                            []
                                                                                                                            rewrite_steps
                                                                                                                              forward_chaining
                                                                                                                              • unroll
                                                                                                                                expr
                                                                                                                                (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2707|
                                                                                                                                                                     …
                                                                                                                                expansions
                                                                                                                                • unroll
                                                                                                                                  expr
                                                                                                                                  (|count_`order list`_2707| (|get.::.1_2678| _x_2702))
                                                                                                                                  expansions
                                                                                                                                  • unroll
                                                                                                                                    expr
                                                                                                                                    (|count_`order list`_2707| _x_2702)
                                                                                                                                    expansions
                                                                                                                                    • unsat
                                                                                                                                      (let ((a!1 (ite (>= (o_qty_50 (|get.::.0_2677| _x_2702)) 0)
                                                                                                                                                      (o_qty_50 (|get.::.0_267…

                                                                                                                                    termination proof

                                                                                                                                    Termination proof

                                                                                                                                    call `recfun.no_lost_qtys.sum_fill_qtys.2 (List.tl _x)` from `recfun.no_lost_qtys.sum_fill_qtys.2 _x`
                                                                                                                                    originalrecfun.no_lost_qtys.sum_fill_qtys.2 _x
                                                                                                                                    subrecfun.no_lost_qtys.sum_fill_qtys.2 (List.tl _x)
                                                                                                                                    original ordinalOrdinal.Int (Ordinal.count _x)
                                                                                                                                    sub ordinalOrdinal.Int (Ordinal.count (List.tl _x))
                                                                                                                                    path[not (_x = [])]
                                                                                                                                    proof
                                                                                                                                    detailed proof
                                                                                                                                    ground_instances3
                                                                                                                                    definitions0
                                                                                                                                    inductions0
                                                                                                                                    search_time
                                                                                                                                    0.016s
                                                                                                                                    details
                                                                                                                                    Expand
                                                                                                                                    smt_stats
                                                                                                                                    num checks8
                                                                                                                                    arith-make-feasible27
                                                                                                                                    arith-max-columns37
                                                                                                                                    arith-conflicts2
                                                                                                                                    rlimit count13756
                                                                                                                                    mk clause39
                                                                                                                                    datatype occurs check36
                                                                                                                                    mk bool var114
                                                                                                                                    arith-lower13
                                                                                                                                    datatype splits6
                                                                                                                                    decisions27
                                                                                                                                    propagations23
                                                                                                                                    arith-max-rows11
                                                                                                                                    conflicts9
                                                                                                                                    datatype accessor ax7
                                                                                                                                    datatype constructor ax10
                                                                                                                                    num allocs2322130082
                                                                                                                                    final checks9
                                                                                                                                    added eqs75
                                                                                                                                    del clause12
                                                                                                                                    arith eq adapter11
                                                                                                                                    arith-upper21
                                                                                                                                    memory33.190000
                                                                                                                                    max memory33.230000
                                                                                                                                    Expand
                                                                                                                                    • start[0.016s]
                                                                                                                                        not (_x = []) && Ordinal.count _x >= 0 && Ordinal.count (List.tl _x) >= 0
                                                                                                                                        ==> List.tl _x = []
                                                                                                                                            || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl _x)))
                                                                                                                                               (Ordinal.Int (Ordinal.count _x))
                                                                                                                                    • simplify
                                                                                                                                      into
                                                                                                                                      (not
                                                                                                                                       ((not (_x = []) && Ordinal.count _x >= 0) && Ordinal.count (List.tl _x) >= 0)
                                                                                                                                       || List.tl _x = [])
                                                                                                                                      || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl _x)))
                                                                                                                                         (Ordinal.Int (Ordinal.count _x))
                                                                                                                                      expansions
                                                                                                                                      []
                                                                                                                                      rewrite_steps
                                                                                                                                        forward_chaining
                                                                                                                                        • unroll
                                                                                                                                          expr
                                                                                                                                          (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`fill list`_2730|
                                                                                                                                                                                …
                                                                                                                                          expansions
                                                                                                                                          • unroll
                                                                                                                                            expr
                                                                                                                                            (|count_`fill list`_2730| (|get.::.1_2724| _x_2725))
                                                                                                                                            expansions
                                                                                                                                            • unroll
                                                                                                                                              expr
                                                                                                                                              (|count_`fill list`_2730| _x_2725)
                                                                                                                                              expansions
                                                                                                                                              • unsat
                                                                                                                                                (let ((a!1 (ite (>= (fill_client_id_116 (|get.::.0_2723| _x_2725)) 0)
                                                                                                                                                                (fill_client_i…

                                                                                                                                              Proved up to 15 steps

                                                                                                                                              2.4 Test generation

                                                                                                                                              First, we will decompose the function and then generate test cases for it.

                                                                                                                                              In [9]:
                                                                                                                                              (* This is a 'side_condition' function that tells decomposition that we're only interested in cases where the 
                                                                                                                                              initial fills are empty *)
                                                                                                                                              let cond (b : book) (fills : fill list) (filled_qty : int) =
                                                                                                                                               fills = [] && filled_qty = 0
                                                                                                                                              ;;
                                                                                                                                              
                                                                                                                                              let d = Modular_decomp.top ~assuming:"cond" "uncross_book" ~prune:true [@@program];;
                                                                                                                                              
                                                                                                                                              Out[9]:
                                                                                                                                              val cond : book -> fill list -> int -> bool = <fun>
                                                                                                                                              val d : Top_result.modular_decomposition =
                                                                                                                                                {Imandra_interactive.Modular_decomp.MD.md_session = 1i;
                                                                                                                                                 md_f =
                                                                                                                                                  {Imandra_surface.Uid.name = "uncross_book"; id = <abstr>;
                                                                                                                                                   special_tag = <abstr>; namespace = <abstr>;
                                                                                                                                                   chash = Some eHLeDDanbjrrHoV+b7+1bMjrWyYC+oVdp/j3tBXPMd4;
                                                                                                                                                   depth = (4i, 6i)};
                                                                                                                                                 md_args = [(b : book); (fills : fill list); (filled_qty : int)];
                                                                                                                                                 md_regions = <abstr>}
                                                                                                                                              
                                                                                                                                              Regions details

                                                                                                                                              No group selected.

                                                                                                                                              • Concrete regions are numbered
                                                                                                                                              • Unnumbered regions are groups whose children share a particular constraint
                                                                                                                                              • Click on a region to view its details
                                                                                                                                              • Double click on a region to zoom in on it
                                                                                                                                              • Shift+double click to zoom out
                                                                                                                                              • Hit escape to reset back to the top
                                                                                                                                              decomp of (uncross_book b, fills, filled_qty
                                                                                                                                              Reg_idConstraintsInvariant
                                                                                                                                              35
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • fills = []
                                                                                                                                              • b.b_sells = []
                                                                                                                                              • b.b_buys = []
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              34
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • fills = []
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • b.b_buys = []
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              33
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • fills = []
                                                                                                                                              • b.b_sells = []
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              28
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_buys).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl b.b_buys;
                                                                                                                                               b_sells =
                                                                                                                                               {List.hd b.b_sells with
                                                                                                                                               o_qty = (List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty} ::
                                                                                                                                               (List.tl b.b_sells)}
                                                                                                                                              ({fill_client_id = (List.hd b.b_sells).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_buys).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true}
                                                                                                                                               ::
                                                                                                                                               ({fill_client_id = (List.hd b.b_buys).o_client_id;
                                                                                                                                                 fill_qty = (List.hd b.b_buys).o_qty;
                                                                                                                                                 fill_price =
                                                                                                                                                 ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                 fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true}
                                                                                                                                                :: fills))
                                                                                                                                              (filled_qty + (List.hd b.b_buys).o_qty)
                                                                                                                                              27
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_buys).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl b.b_buys;
                                                                                                                                               b_sells =
                                                                                                                                               {List.hd b.b_sells with
                                                                                                                                               o_qty = (List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty} ::
                                                                                                                                               (List.tl b.b_sells)}
                                                                                                                                              ({fill_client_id = (List.hd b.b_sells).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_buys).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + (List.hd b.b_buys).o_qty)
                                                                                                                                              26
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_buys).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl b.b_buys;
                                                                                                                                               b_sells =
                                                                                                                                               {List.hd b.b_sells with
                                                                                                                                               o_qty = (List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty} ::
                                                                                                                                               (List.tl b.b_sells)}
                                                                                                                                              ({fill_client_id = (List.hd b.b_buys).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_buys).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + (List.hd b.b_buys).o_qty)
                                                                                                                                              25
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_buys).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl b.b_buys;
                                                                                                                                               b_sells =
                                                                                                                                               {List.hd b.b_sells with
                                                                                                                                               o_qty = (List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty} ::
                                                                                                                                               (List.tl b.b_sells)}
                                                                                                                                              fills (filled_qty + (List.hd b.b_buys).o_qty)
                                                                                                                                              16
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book {b_buys = List.tl b.b_buys; b_sells = List.tl b.b_sells}
                                                                                                                                              ({fill_client_id = (List.hd b.b_sells).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true}
                                                                                                                                               ::
                                                                                                                                               ({fill_client_id = (List.hd b.b_buys).o_client_id;
                                                                                                                                                 fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                 fill_price =
                                                                                                                                                 ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                 fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true}
                                                                                                                                                :: fills))
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              15
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book {b_buys = List.tl b.b_buys; b_sells = List.tl b.b_sells}
                                                                                                                                              ({fill_client_id = (List.hd b.b_sells).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              14
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book {b_buys = List.tl b.b_buys; b_sells = List.tl b.b_sells}
                                                                                                                                              ({fill_client_id = (List.hd b.b_buys).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              13
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book {b_buys = List.tl b.b_buys; b_sells = List.tl b.b_sells} fills
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              8
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys =
                                                                                                                                               {List.hd b.b_buys with
                                                                                                                                               o_qty = (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty} ::
                                                                                                                                               (List.tl b.b_buys); b_sells = List.tl b.b_sells}
                                                                                                                                              ({fill_client_id = (List.hd b.b_sells).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true}
                                                                                                                                               ::
                                                                                                                                               ({fill_client_id = (List.hd b.b_buys).o_client_id;
                                                                                                                                                 fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                 fill_price =
                                                                                                                                                 ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                 fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true}
                                                                                                                                                :: fills))
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              7
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys =
                                                                                                                                               {List.hd b.b_buys with
                                                                                                                                               o_qty = (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty} ::
                                                                                                                                               (List.tl b.b_buys); b_sells = List.tl b.b_sells}
                                                                                                                                              ({fill_client_id = (List.hd b.b_sells).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_sells).o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              6
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys =
                                                                                                                                               {List.hd b.b_buys with
                                                                                                                                               o_qty = (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty} ::
                                                                                                                                               (List.tl b.b_buys); b_sells = List.tl b.b_sells}
                                                                                                                                              ({fill_client_id = (List.hd b.b_buys).o_client_id;
                                                                                                                                                fill_qty = (List.hd b.b_sells).o_qty;
                                                                                                                                                fill_price = ((List.hd b.b_buys).o_price + (List.hd b.b_sells).o_price) / 2;
                                                                                                                                                fill_order_id = (List.hd b.b_buys).o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              5
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys =
                                                                                                                                               {List.hd b.b_buys with
                                                                                                                                               o_qty = (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty} ::
                                                                                                                                               (List.tl b.b_buys); b_sells = List.tl b.b_sells}
                                                                                                                                              fills (filled_qty + (List.hd b.b_sells).o_qty)
                                                                                                                                              0
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price)
                                                                                                                                              • not (b.b_sells = [])
                                                                                                                                              • not (b.b_buys = [])
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              In [10]:
                                                                                                                                              (* Now let's try to generate some test cases *)
                                                                                                                                              
                                                                                                                                              (* This will auto-generate model extractor *)
                                                                                                                                              Extract.eval ~quiet:true ~signature:(Event.DB.fun_id_of_str "uncross_book") ();;
                                                                                                                                              
                                                                                                                                              #remove_doc doc_of_book;;
                                                                                                                                              #remove_doc doc_of_order;;
                                                                                                                                              Modular_decomp.get_regions d |> CCList.map (fun r -> r |> Modular_decomp.get_model |> Mex.of_model);;
                                                                                                                                              #install_doc doc_of_order;;
                                                                                                                                              #install_doc doc_of_book;;
                                                                                                                                              
                                                                                                                                              Out[10]:
                                                                                                                                                                                  - : unit = ()
                                                                                                                                              - : Mex.extract_type list =
                                                                                                                                              [{Mex.b = {b_buys = []; b_sells = []}; fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys = [];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 3; o_price = 4; o_time = 0; o_id = 1; o_side = BUY;
                                                                                                                                                     o_client_id = 2; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 3; o_price = 4; o_time = 0; o_id = 1; o_side = BUY;
                                                                                                                                                     o_client_id = 2; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells = []};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = -1; o_price = 21238; o_time = 3; o_id = 2; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -7719; o_time = 6; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = -1; o_price = 21238; o_time = 2; o_id = 4; o_side = BUY;
                                                                                                                                                     o_client_id = 3; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -7719; o_time = 5; o_id = 7; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = -1; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = -1; o_price = 21238; o_time = 2; o_id = 4; o_side = BUY;
                                                                                                                                                     o_client_id = 3; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 1; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 1; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 1; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 1; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 2; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 1; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 1; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               ...]
                                                                                                                                              

                                                                                                                                              3 Implied trading

                                                                                                                                              3.1 Strategy ranking

                                                                                                                                              When generating implied orders for strategies, there's a criteria used to rank strategies - this section encodes the comparison function.

                                                                                                                                              In [11]:
                                                                                                                                              (* Calculate somehow how big the ratio is *)
                                                                                                                                              let leg_ratio (s : strategy) = 
                                                                                                                                                let abs x = if x < 0 then -x else x in
                                                                                                                                                (abs s.leg1.leg_mult) + (abs s.leg2.leg_mult) + (abs s.leg3.leg_mult)
                                                                                                                                              ;;
                                                                                                                                              
                                                                                                                                              (* Nearest time to expiry *)
                                                                                                                                              let nearest_time_to_exp (s : strategy) =
                                                                                                                                                let exp = 
                                                                                                                                                  if (month_to_int (contract_expiry s.leg1.leg_sec_idx)) < (month_to_int (contract_expiry s.leg2.leg_sec_idx)) then
                                                                                                                                                    contract_expiry s.leg1.leg_sec_idx
                                                                                                                                                  else
                                                                                                                                                    contract_expiry s.leg2.leg_sec_idx in
                                                                                                                                                
                                                                                                                                                if (month_to_int exp) < (month_to_int (contract_expiry s.leg2.leg_sec_idx)) then
                                                                                                                                                  exp
                                                                                                                                                else
                                                                                                                                                  contract_expiry s.leg2.leg_sec_idx
                                                                                                                                              ;;
                                                                                                                                              
                                                                                                                                              (* Return true if s1 should implied uncross before s2 *)
                                                                                                                                              let priority_strat (s1 : strategy) (s2 : strategy) =
                                                                                                                                                (*
                                                                                                                                                  1. time to expiry of the nearest leg
                                                                                                                                                  2. strategy types (strategies with the greater leg ratio executed first)
                                                                                                                                                  3. strategy creation times *)
                                                                                                                                                if (month_to_int (nearest_time_to_exp s1)) < (month_to_int (nearest_time_to_exp s2)) then
                                                                                                                                                  true
                                                                                                                                                else 
                                                                                                                                                  if (leg_ratio s1) > (leg_ratio s2) then
                                                                                                                                                    true
                                                                                                                                                  else
                                                                                                                                                    s1.time_created <= s2.time_created
                                                                                                                                              
                                                                                                                                              Out[11]:
                                                                                                                                              val leg_ratio : strategy -> int = <fun>
                                                                                                                                              val nearest_time_to_exp : strategy -> month = <fun>
                                                                                                                                              val priority_strat : strategy -> strategy -> bool = <fun>
                                                                                                                                              
                                                                                                                                              In [12]:
                                                                                                                                              let transitivity s1 s2 s3 =
                                                                                                                                               ((priority_strat s1 s2) && (priority_strat s2 s3)) ==> (priority_strat s1 s3)
                                                                                                                                               
                                                                                                                                              verify transitivity
                                                                                                                                              
                                                                                                                                              Out[12]:
                                                                                                                                              val transitivity : strategy -> strategy -> strategy -> bool = <fun>
                                                                                                                                              - : strategy -> strategy -> strategy -> bool = <fun>
                                                                                                                                              module CX : sig val s1 : strategy val s2 : strategy val s3 : strategy end
                                                                                                                                              
                                                                                                                                              Counterexample (after 0 steps, 0.030s):
                                                                                                                                               let (s1 : strategy) =
                                                                                                                                                 {time_created = 0; leg1 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                  leg2 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                  leg3 = {leg_sec_idx = OUT1; leg_mult = 1}}
                                                                                                                                               let (s2 : strategy) =
                                                                                                                                                 {time_created = 281; leg1 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                  leg2 = {leg_sec_idx = OUT3; leg_mult = 0};
                                                                                                                                                  leg3 = {leg_sec_idx = OUT1; leg_mult = 2}}
                                                                                                                                               let (s3 : strategy) =
                                                                                                                                                 {time_created = (-1); leg1 = {leg_sec_idx = OUT3; leg_mult = 0};
                                                                                                                                                  leg2 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                  leg3 = {leg_sec_idx = OUT1; leg_mult = 0}}
                                                                                                                                              
                                                                                                                                              Refuted
                                                                                                                                              proof attempt
                                                                                                                                              ground_instances0
                                                                                                                                              definitions0
                                                                                                                                              inductions0
                                                                                                                                              search_time
                                                                                                                                              0.030s
                                                                                                                                              details
                                                                                                                                              Expand
                                                                                                                                              smt_stats
                                                                                                                                              num checks1
                                                                                                                                              arith-assume-eqs7
                                                                                                                                              arith-make-feasible332
                                                                                                                                              arith-max-columns75
                                                                                                                                              arith-conflicts3
                                                                                                                                              rlimit count21656
                                                                                                                                              arith-cheap-eqs45
                                                                                                                                              mk clause649
                                                                                                                                              datatype occurs check21
                                                                                                                                              mk bool var777
                                                                                                                                              arith-lower254
                                                                                                                                              arith-diseq28
                                                                                                                                              datatype splits42
                                                                                                                                              decisions630
                                                                                                                                              arith-propagations101
                                                                                                                                              propagations962
                                                                                                                                              interface eqs7
                                                                                                                                              arith-bound-propagations-cheap101
                                                                                                                                              arith-max-rows41
                                                                                                                                              conflicts34
                                                                                                                                              datatype accessor ax17
                                                                                                                                              minimized lits5
                                                                                                                                              arith-bound-propagations-lp16
                                                                                                                                              datatype constructor ax107
                                                                                                                                              final checks8
                                                                                                                                              added eqs1179
                                                                                                                                              del clause254
                                                                                                                                              arith eq adapter237
                                                                                                                                              arith-upper363
                                                                                                                                              memory41.240000
                                                                                                                                              max memory86.910000
                                                                                                                                              num allocs7949528193.000000
                                                                                                                                              Expand
                                                                                                                                              • start[0.030s]
                                                                                                                                                  (if (if (if (if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                <
                                                                                                                                                                (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                             then
                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                             else
                                                                                                                                                             if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                             else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                           else
                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Mar
                                                                                                                                                       then 3
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                <
                                                                                                                                                                (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                             then if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                             else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                           else
                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Jun
                                                                                                                                                       then 6
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                <
                                                                                                                                                                (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                             then … else …
                                                                                                                                                           else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                          = Sep
                                                                                                                                                       then 9 else 12)
                                                                                                                                                      <
                                                                                                                                                      (if (if (if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                <
                                                                                                                                                                (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                             then
                                                                                                                                                               if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                             else
                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                             else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                           else
                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Mar
                                                                                                                                                       then 3
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                <
                                                                                                                                                                (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                             then if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                             else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                           else
                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Jun
                                                                                                                                                       then 6
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                   else
                                                                                                                                                                   if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                      <
                                                                                                                                                                      (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Mar
                                                                                                                                                                       then 3
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Jun
                                                                                                                                                                       then 6
                                                                                                                                                                       else
                                                                                                                                                                       if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                           else
                                                                                                                                                                           if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                           else Sep)
                                                                                                                                                                          = Sep
                                                                                                                                                                       then 9 else 12)
                                                                                                                                                                   then if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                <
                                                                                                                                                                (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Mar
                                                                                                                                                                 then 3
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Jun
                                                                                                                                                                 then 6
                                                                                                                                                                 else
                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                     else
                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                    = Sep
                                                                                                                                                                 then 9 else 12)
                                                                                                                                                             then … else …
                                                                                                                                                           else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                          = Sep
                                                                                                                                                       then 9 else 12)
                                                                                                                                                   then true
                                                                                                                                                   else
                                                                                                                                                   if (((if :var_0:.leg1.leg_mult < 0 then ~- :var_0:.leg1.leg_mult
                                                                                                                                                         else :var_0:.leg1.leg_mult)
                                                                                                                                                        + (if :var_0:.leg2.leg_mult < 0 then ~- :var_0:.leg2.leg_mult
                                                                                                                                                           else :var_0:.leg2.leg_mult))
                                                                                                                                                       + (if :var_0:.leg3.leg_mult < 0 then ~- :var_0:.leg3.leg_mult
                                                                                                                                                          else :var_0:.leg3.leg_mult))
                                                                                                                                                      >
                                                                                                                                                      (((if :var_1:.leg1.leg_mult < 0 then ~- :var_1:.leg1.leg_mult
                                                                                                                                                         else :var_1:.leg1.leg_mult)
                                                                                                                                                        + (if :var_1:.leg2.leg_mult < 0 then ~- :var_1:.leg2.leg_mult
                                                                                                                                                           else :var_1:.leg2.leg_mult))
                                                                                                                                                       + (if :var_1:.leg3.leg_mult < 0 then ~- :var_1:.leg3.leg_mult
                                                                                                                                                          else :var_1:.leg3.leg_mult))
                                                                                                                                                   then true else :var_0:.time_created <= :var_1:.time_created)
                                                                                                                                                  && (if (if (if (if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <
                                                                                                                                                                 (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                              then
                                                                                                                                                                if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                   <
                                                                                                                                                                   (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                then
                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                  else if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                else
                                                                                                                                                                if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                              else
                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                              else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                             = Mar
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if (if (if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <
                                                                                                                                                                 (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                              then
                                                                                                                                                                if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                   <
                                                                                                                                                                   (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                then if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                              else
                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                              else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                             = Jun
                                                                                                                                                          then 6
                                                                                                                                                          else
                                                                                                                                                          if (if (if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <
                                                                                                                                                                 (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                              then
                                                                                                                                                                if (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                   <
                                                                                                                                                                   (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                then … else …
                                                                                                                                                              else if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                             = Sep
                                                                                                                                                          then 9 else 12)
                                                                                                                                                         <
                                                                                                                                                         (if (if (if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <
                                                                                                                                                                 (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                              then
                                                                                                                                                                if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                   <
                                                                                                                                                                   (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                then
                                                                                                                                                                  if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                  else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                else
                                                                                                                                                                if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                              else
                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                              else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                             = Mar
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if (if (if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <
                                                                                                                                                                 (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                              then
                                                                                                                                                                if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                   <
                                                                                                                                                                   (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                then if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                else if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                              else
                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                              else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                             = Jun
                                                                                                                                                          then 6
                                                                                                                                                          else
                                                                                                                                                          if (if (if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <
                                                                                                                                                                         (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <
                                                                                                                                                                 (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                              then
                                                                                                                                                                if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                   <
                                                                                                                                                                   (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Mar
                                                                                                                                                                    then 3
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Jun
                                                                                                                                                                    then 6
                                                                                                                                                                    else
                                                                                                                                                                    if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                       = Sep
                                                                                                                                                                    then 9 else 12)
                                                                                                                                                                then … else …
                                                                                                                                                              else if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                             = Sep
                                                                                                                                                          then 9 else 12)
                                                                                                                                                      then true
                                                                                                                                                      else
                                                                                                                                                      if (((if :var_1:.leg1.leg_mult < 0 then ~- :var_1:.leg1.leg_mult
                                                                                                                                                            else :var_1:.leg1.leg_mult)
                                                                                                                                                           + (if :var_1:.leg2.leg_mult < 0 then ~- :var_1:.leg2.leg_mult
                                                                                                                                                              else :var_1:.leg2.leg_mult))
                                                                                                                                                          + (if :var_1:.leg3.leg_mult < 0 then ~- :var_1:.leg3.leg_mult
                                                                                                                                                             else :var_1:.leg3.leg_mult))
                                                                                                                                                         >
                                                                                                                                                         (((if :var_2:.leg1.leg_mult < 0 then ~- :var_2:.leg1.leg_mult
                                                                                                                                                            else :var_2:.leg1.leg_mult)
                                                                                                                                                           + (if :var_2:.leg2.leg_mult < 0 then ~- :var_2:.leg2.leg_mult
                                                                                                                                                              else :var_2:.leg2.leg_mult))
                                                                                                                                                          + (if :var_2:.leg3.leg_mult < 0 then ~- :var_2:.leg3.leg_mult
                                                                                                                                                             else :var_2:.leg3.leg_mult))
                                                                                                                                                      then true else :var_1:.time_created <= :var_2:.time_created)
                                                                                                                                                  ==> (if (if (if (if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <
                                                                                                                                                                  (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                    <
                                                                                                                                                                    (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                 then
                                                                                                                                                                   if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                 else
                                                                                                                                                                 if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                 else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                               else
                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Mar
                                                                                                                                                           then 3
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <
                                                                                                                                                                  (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                    <
                                                                                                                                                                    (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                 then if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                 else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                               else
                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Jun
                                                                                                                                                           then 6
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <
                                                                                                                                                                  (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                    <
                                                                                                                                                                    (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                 then … else …
                                                                                                                                                               else if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                              = Sep
                                                                                                                                                           then 9 else 12)
                                                                                                                                                          <
                                                                                                                                                          (if (if (if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <
                                                                                                                                                                  (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                    <
                                                                                                                                                                    (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                 then
                                                                                                                                                                   if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                 else
                                                                                                                                                                 if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                 else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                               else
                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Mar
                                                                                                                                                           then 3
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <
                                                                                                                                                                  (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                    <
                                                                                                                                                                    (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                 then if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                 else if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                               else
                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Jun
                                                                                                                                                           then 6
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                          <
                                                                                                                                                                          (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Mar
                                                                                                                                                                           then 3
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Jun
                                                                                                                                                                           then 6
                                                                                                                                                                           else
                                                                                                                                                                           if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep)
                                                                                                                                                                              = Sep
                                                                                                                                                                           then 9 else 12)
                                                                                                                                                                       then
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <
                                                                                                                                                                  (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                    <
                                                                                                                                                                    (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Mar
                                                                                                                                                                     then 3
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Jun
                                                                                                                                                                     then 6
                                                                                                                                                                     else
                                                                                                                                                                     if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                         else
                                                                                                                                                                         if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                        = Sep
                                                                                                                                                                     then 9 else 12)
                                                                                                                                                                 then … else …
                                                                                                                                                               else if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                              = Sep
                                                                                                                                                           then 9 else 12)
                                                                                                                                                       then true
                                                                                                                                                       else
                                                                                                                                                       if (((if :var_0:.leg1.leg_mult < 0 then ~- :var_0:.leg1.leg_mult
                                                                                                                                                             else :var_0:.leg1.leg_mult)
                                                                                                                                                            + (if :var_0:.leg2.leg_mult < 0 then ~- :var_0:.leg2.leg_mult
                                                                                                                                                               else :var_0:.leg2.leg_mult))
                                                                                                                                                           + (if :var_0:.leg3.leg_mult < 0 then ~- :var_0:.leg3.leg_mult
                                                                                                                                                              else :var_0:.leg3.leg_mult))
                                                                                                                                                          >
                                                                                                                                                          (((if :var_2:.leg1.leg_mult < 0 then ~- :var_2:.leg1.leg_mult
                                                                                                                                                             else :var_2:.leg1.leg_mult)
                                                                                                                                                            + (if :var_2:.leg2.leg_mult < 0 then ~- :var_2:.leg2.leg_mult
                                                                                                                                                               else :var_2:.leg2.leg_mult))
                                                                                                                                                           + (if :var_2:.leg3.leg_mult < 0 then ~- :var_2:.leg3.leg_mult
                                                                                                                                                              else :var_2:.leg3.leg_mult))
                                                                                                                                                       then true else :var_0:.time_created <= :var_2:.time_created)
                                                                                                                                              • simplify

                                                                                                                                                into
                                                                                                                                                ((:var_0:.time_created <= :var_2:.time_created
                                                                                                                                                  || not
                                                                                                                                                     ((if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <=
                                                                                                                                                              (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              || (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <=
                                                                                                                                                                 (if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                             else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                           else
                                                                                                                                                           if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Mar
                                                                                                                                                       then 3
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <=
                                                                                                                                                              (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              || (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <=
                                                                                                                                                                 (if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                             else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                           else
                                                                                                                                                           if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Jun
                                                                                                                                                       then 6
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <=
                                                                                                                                                              (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              || (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <=
                                                                                                                                                                 (if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                           then if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                           else if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                          = Sep
                                                                                                                                                       then 9 else 12)
                                                                                                                                                      <=
                                                                                                                                                      (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <=
                                                                                                                                                              (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              || (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <=
                                                                                                                                                                 (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                             else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                           else
                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Mar
                                                                                                                                                       then 3
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <=
                                                                                                                                                              (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              || (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <=
                                                                                                                                                                 (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                             else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                           else
                                                                                                                                                           if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                           else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                          = Jun
                                                                                                                                                       then 6
                                                                                                                                                       else
                                                                                                                                                       if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              <=
                                                                                                                                                              (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Mar
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Jun
                                                                                                                                                               then 6
                                                                                                                                                               else
                                                                                                                                                               if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                   else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                  = Sep
                                                                                                                                                               then 9 else 12)
                                                                                                                                                              || (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                                 <=
                                                                                                                                                                 (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Mar
                                                                                                                                                                  then 3
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                        else
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                     = Jun
                                                                                                                                                                  then 6
                                                                                                                                                                  else
                                                                                                                                                                  if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                         <=
                                                                                                                                                                         (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Mar
                                                                                                                                                                          then 3
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Jun
                                                                                                                                                                          then 6
                                                                                                                                                                          else
                                                                                                                                                                          if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                              else
                                                                                                                                                                              if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                              else Sep)
                                                                                                                                                                             = Sep
                                                                                                                                                                          then 9 else 12)
                                                                                                                                                                      then
                                                                                                                                                                        if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                      else
                                                                                                                                                                      if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                     = Sep
                                                                                                                                                                  then 9 else 12)
                                                                                                                                                           then if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                           else if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                          = Sep
                                                                                                                                                       then 9 else 12)))
                                                                                                                                                 || not
                                                                                                                                                    ((((if 0 <= :var_0:.leg1.leg_mult then :var_0:.leg1.leg_mult
                                                                                                                                                        else -1 * :var_0:.leg1.leg_mult)
                                                                                                                                                       + (if 0 <= :var_0:.leg2.leg_mult then :var_0:.leg2.leg_mult
                                                                                                                                                          else -1 * :var_0:.leg2.leg_mult))
                                                                                                                                                      + (if 0 <= :var_0:.leg3.leg_mult then :var_0:.leg3.leg_mult
                                                                                                                                                         else -1 * :var_0:.leg3.leg_mult))
                                                                                                                                                     <=
                                                                                                                                                     (((if 0 <= :var_2:.leg1.leg_mult then :var_2:.leg1.leg_mult
                                                                                                                                                        else -1 * :var_2:.leg1.leg_mult)
                                                                                                                                                       + (if 0 <= :var_2:.leg2.leg_mult then :var_2:.leg2.leg_mult
                                                                                                                                                          else -1 * :var_2:.leg2.leg_mult))
                                                                                                                                                      + (if 0 <= :var_2:.leg3.leg_mult then :var_2:.leg3.leg_mult
                                                                                                                                                         else -1 * :var_2:.leg3.leg_mult))))
                                                                                                                                                || not
                                                                                                                                                   (((:var_0:.time_created <= :var_1:.time_created
                                                                                                                                                      || not
                                                                                                                                                         ((if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <=
                                                                                                                                                                  (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  || (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else …
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else …)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                 else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                               else
                                                                                                                                                               if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Mar
                                                                                                                                                           then 3
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <=
                                                                                                                                                                  (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  || (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else …
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else …)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                 else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                               else
                                                                                                                                                               if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Jun
                                                                                                                                                           then 6
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <=
                                                                                                                                                                  (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  || (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_1:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else …
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else …)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                               then if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                               else if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                              = Sep
                                                                                                                                                           then 9 else 12)
                                                                                                                                                          <=
                                                                                                                                                          (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <=
                                                                                                                                                                  (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  || (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else …
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else …)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                 else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                               else
                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Mar
                                                                                                                                                           then 3
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <=
                                                                                                                                                                  (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  || (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else …
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else …)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                               then
                                                                                                                                                                 if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                 else if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                               else
                                                                                                                                                               if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                               else if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                              = Jun
                                                                                                                                                           then 6
                                                                                                                                                           else
                                                                                                                                                           if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg2.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  <=
                                                                                                                                                                  (if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Mar
                                                                                                                                                                   then 3
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Jun
                                                                                                                                                                   then 6
                                                                                                                                                                   else
                                                                                                                                                                   if (if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                       else
                                                                                                                                                                       if :var_0:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                      = Sep
                                                                                                                                                                   then 9 else 12)
                                                                                                                                                                  || (if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                            else Sep
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if (if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg2.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg2.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                             <=
                                                                                                                                                                             (if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Mar
                                                                                                                                                                              then 3
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Jun
                                                                                                                                                                              then 6
                                                                                                                                                                              else
                                                                                                                                                                              if (if :var_0:.leg1.leg_sec_idx = OUT1 
                                                                                                                                                                                  then Mar
                                                                                                                                                                                  else
                                                                                                                                                                                  if :var_0:.leg1.leg_sec_idx = OUT2 
                                                                                                                                                                                  then Jun else Sep)
                                                                                                                                                                                 = Sep
                                                                                                                                                                              then 9 else 12)
                                                                                                                                                                          then
                                                                                                                                                                            if :var_0:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                            else …
                                                                                                                                                                          else
                                                                                                                                                                          if :var_0:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else …)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                               then if :var_0:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                               else if :var_0:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                              = Sep
                                                                                                                                                           then 9 else 12)))
                                                                                                                                                     || not
                                                                                                                                                        ((((if 0 <= :var_0:.leg1.leg_mult then :var_0:.leg1.leg_mult
                                                                                                                                                            else -1 * :var_0:.leg1.leg_mult)
                                                                                                                                                           + (if 0 <= :var_0:.leg2.leg_mult then :var_0:.leg2.leg_mult
                                                                                                                                                              else -1 * :var_0:.leg2.leg_mult))
                                                                                                                                                          + (if 0 <= :var_0:.leg3.leg_mult then :var_0:.leg3.leg_mult
                                                                                                                                                             else -1 * :var_0:.leg3.leg_mult))
                                                                                                                                                         <=
                                                                                                                                                         (((if 0 <= :var_1:.leg1.leg_mult then :var_1:.leg1.leg_mult
                                                                                                                                                            else -1 * :var_1:.leg1.leg_mult)
                                                                                                                                                           + (if 0 <= :var_1:.leg2.leg_mult then :var_1:.leg2.leg_mult
                                                                                                                                                              else -1 * :var_1:.leg2.leg_mult))
                                                                                                                                                          + (if 0 <= :var_1:.leg3.leg_mult then :var_1:.leg3.leg_mult
                                                                                                                                                             else -1 * :var_1:.leg3.leg_mult))))
                                                                                                                                                    && ((:var_1:.time_created <= :var_2:.time_created
                                                                                                                                                         || not
                                                                                                                                                            ((if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     || (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                        <=
                                                                                                                                                                        (if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else …
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else …)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                  then
                                                                                                                                                                    if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                    else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                  else
                                                                                                                                                                  if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                  else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                 = Mar
                                                                                                                                                              then 3
                                                                                                                                                              else
                                                                                                                                                              if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     || (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                        <=
                                                                                                                                                                        (if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else …
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else …)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                  then
                                                                                                                                                                    if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                    else if :var_2:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                  else
                                                                                                                                                                  if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                  else if :var_2:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                 = Jun
                                                                                                                                                              then 6
                                                                                                                                                              else
                                                                                                                                                              if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     || (if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                        <=
                                                                                                                                                                        (if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_2:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_2:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_2:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else …
                                                                                                                                                                             else
                                                                                                                                                                             if :var_2:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else …)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                  then if :var_2:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                  else if :var_2:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                 = Sep
                                                                                                                                                              then 9 else 12)
                                                                                                                                                             <=
                                                                                                                                                             (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     || (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                        <=
                                                                                                                                                                        (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else …
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else …)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                  then
                                                                                                                                                                    if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                    else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                  else
                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                  else if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                 = Mar
                                                                                                                                                              then 3
                                                                                                                                                              else
                                                                                                                                                              if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     || (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                        <=
                                                                                                                                                                        (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else …
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else …)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                  then
                                                                                                                                                                    if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                    else if :var_1:.leg2.leg_sec_idx = OUT2 then Jun else Sep
                                                                                                                                                                  else
                                                                                                                                                                  if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                  else if :var_1:.leg1.leg_sec_idx = OUT2 then Jun else Sep)
                                                                                                                                                                 = Jun
                                                                                                                                                              then 6
                                                                                                                                                              else
                                                                                                                                                              if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     <=
                                                                                                                                                                     (if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Mar
                                                                                                                                                                      then 3
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Jun
                                                                                                                                                                      then 6
                                                                                                                                                                      else
                                                                                                                                                                      if (if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                          else
                                                                                                                                                                          if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                          else Sep)
                                                                                                                                                                         = Sep
                                                                                                                                                                      then 9 else 12)
                                                                                                                                                                     || (if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                        <=
                                                                                                                                                                        (if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Mar
                                                                                                                                                                         then 3
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                               else Sep
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT2 then Jun
                                                                                                                                                                             else Sep)
                                                                                                                                                                            = Jun
                                                                                                                                                                         then 6
                                                                                                                                                                         else
                                                                                                                                                                         if (if (if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg2.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg2.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                                <=
                                                                                                                                                                                (if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Mar
                                                                                                                                                                                 then 3
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Jun
                                                                                                                                                                                 then 6
                                                                                                                                                                                 else
                                                                                                                                                                                 if (if :var_1:.leg1.leg_sec_idx = OUT1
                                                                                                                                                                                     then Mar
                                                                                                                                                                                     else
                                                                                                                                                                                     if :var_1:.leg1.leg_sec_idx = OUT2
                                                                                                                                                                                     then Jun else Sep)
                                                                                                                                                                                    = Sep
                                                                                                                                                                                 then 9 else 12)
                                                                                                                                                                             then
                                                                                                                                                                               if :var_1:.leg2.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                               else …
                                                                                                                                                                             else
                                                                                                                                                                             if :var_1:.leg1.leg_sec_idx = OUT1 then Mar
                                                                                                                                                                             else …)
                                                                                                                                                                            = Sep
                                                                                                                                                                         then 9 else 12)
                                                                                                                                                                  then if :var_1:.leg2.leg_sec_idx = OUT1 then Mar else …
                                                                                                                                                                  else if :var_1:.leg1.leg_sec_idx = OUT1 then Mar else …)
                                                                                                                                                                 = Sep
                                                                                                                                                              then 9 else 12)))
                                                                                                                                                        || not
                                                                                                                                                           ((((if 0 <= :var_1:.leg1.leg_mult then :var_1:.leg1.leg_mult
                                                                                                                                                               else -1 * :var_1:.leg1.leg_mult)
                                                                                                                                                              + (if 0 <= :var_1:.leg2.leg_mult then :var_1:.leg2.leg_mult
                                                                                                                                                                 else -1 * :var_1:.leg2.leg_mult))
                                                                                                                                                             + (if 0 <= :var_1:.leg3.leg_mult then :var_1:.leg3.leg_mult
                                                                                                                                                                else -1 * :var_1:.leg3.leg_mult))
                                                                                                                                                            <=
                                                                                                                                                            (((if 0 <= :var_2:.leg1.leg_mult then :var_2:.leg1.leg_mult
                                                                                                                                                               else -1 * :var_2:.leg1.leg_mult)
                                                                                                                                                              + (if 0 <= :var_2:.leg2.leg_mult then :var_2:.leg2.leg_mult
                                                                                                                                                                 else -1 * :var_2:.leg2.leg_mult))
                                                                                                                                                             + (if 0 <= :var_2:.leg3.leg_mult then :var_2:.leg3.leg_mult
                                                                                                                                                                else -1 * :var_2:.leg3.leg_mult)))))
                                                                                                                                                expansions
                                                                                                                                                []
                                                                                                                                                rewrite_steps
                                                                                                                                                  forward_chaining
                                                                                                                                                  • Sat (Some let (s1 : strategy) = {time_created = 0; leg1 = {leg_sec_idx = OUT2; leg_mult = 0}; leg2 = {leg_sec_idx = OUT1; leg_mult = 0}; leg3 = {leg_sec_idx = OUT1; leg_mult = 1}} let (s2 : strategy) = {time_created = 281; leg1 = {leg_sec_idx = OUT1; leg_mult = 0}; leg2 = {leg_sec_idx = OUT3; leg_mult = 0}; leg3 = {leg_sec_idx = OUT1; leg_mult = 2}} let (s3 : strategy) = {time_created = (-1); leg1 = {leg_sec_idx = OUT3; leg_mult = 0}; leg2 = {leg_sec_idx = OUT1; leg_mult = 1}; leg3 = {leg_sec_idx = OUT1; leg_mult = 0}} )

                                                                                                                                                  Ooops! It seems that our ranking criteria is not transitive. Let's check the results (note that the counter examples are now reflected into the run time in the CX module)

                                                                                                                                                  In [13]:
                                                                                                                                                  priority_strat CX.s1 CX.s2
                                                                                                                                                  
                                                                                                                                                  Out[13]:
                                                                                                                                                  - : bool = true
                                                                                                                                                  
                                                                                                                                                  In [14]:
                                                                                                                                                  priority_strat CX.s2 CX.s3
                                                                                                                                                  
                                                                                                                                                  Out[14]:
                                                                                                                                                  - : bool = true
                                                                                                                                                  
                                                                                                                                                  In [15]:
                                                                                                                                                  priority_strat CX.s1 CX.s3
                                                                                                                                                  
                                                                                                                                                  Out[15]:
                                                                                                                                                  - : bool = false
                                                                                                                                                  

                                                                                                                                                  3.2 Implied strategy price calculation

                                                                                                                                                  In [16]:
                                                                                                                                                  (* return the sum of volume at the highest level *)
                                                                                                                                                  let rec get_level_sums (orders : order list) (li : level_info option) =
                                                                                                                                                    match orders with 
                                                                                                                                                    | [] -> li
                                                                                                                                                    | x::xs ->
                                                                                                                                                      begin
                                                                                                                                                        match li with
                                                                                                                                                        | None -> get_level_sums xs (Some {li_qty = x.o_qty; li_price = x.o_price})
                                                                                                                                                        | Some l ->
                                                                                                                                                          if (l.li_price = x.o_price) then
                                                                                                                                                            get_level_sums xs (Some {l with li_qty = l.li_qty + x.o_qty})
                                                                                                                                                          else
                                                                                                                                                            li
                                                                                                                                                      end
                                                                                                                                                  
                                                                                                                                                  (* Return best bid/ask levels *)
                                                                                                                                                  let get_book_tops (b : book) = 
                                                                                                                                                    let bid_info = get_level_sums b.b_buys None in
                                                                                                                                                    let ask_info = get_level_sums b.b_sells None in
                                                                                                                                                    { bid_info; ask_info }
                                                                                                                                                  ;;
                                                                                                                                                  
                                                                                                                                                  (* Get the maximum number of strategy units here *)
                                                                                                                                                  (* Note that the units may have different signs, so we 
                                                                                                                                                   need to make sure that we have enough *)
                                                                                                                                                  let calc_implied_strat_order (sid : strategy_id) (s : strategy) (books : books_info) (si : side) (time : int) =
                                                                                                                                                    let abs x = if x < 0 then -x else x in
                                                                                                                                                  
                                                                                                                                                    let adjust (mult : int) =
                                                                                                                                                      if si = BUY then mult else -mult in
                                                                                                                                                  
                                                                                                                                                    (* *)
                                                                                                                                                    let calc_max_out_mult (mult : int) (book : best_bid_ask)  =
                                                                                                                                                      if mult = 0 then
                                                                                                                                                        None
                                                                                                                                                      else
                                                                                                                                                        begin
                                                                                                                                                         if (adjust mult) > 0 then
                                                                                                                                                          match books.book1.bid_info with
                                                                                                                                                             | Some x -> Some (x.li_qty / (abs mult))
                                                                                                                                                             | None -> None
                                                                                                                                                         else
                                                                                                                                                             match book.ask_info with
                                                                                                                                                             | Some x -> Some (x.li_qty / (abs mult))
                                                                                                                                                             | None -> None
                                                                                                                                                        end in
                                                                                                                                                  
                                                                                                                                                    let mult1 = calc_max_out_mult s.leg1.leg_mult books.book1 in
                                                                                                                                                    let mult2 = calc_max_out_mult s.leg2.leg_mult books.book2 in
                                                                                                                                                    let mult3 = calc_max_out_mult s.leg3.leg_mult books.book3 in
                                                                                                                                                  
                                                                                                                                                    (* Compute the quantity *)
                                                                                                                                                    let max_strat = 
                                                                                                                                                      begin 
                                                                                                                                                         match mult1 with 
                                                                                                                                                         | None -> 0
                                                                                                                                                         | Some x -> x
                                                                                                                                                      end in
                                                                                                                                                    let max_strat = 
                                                                                                                                                      begin
                                                                                                                                                         match mult2 with
                                                                                                                                                         | None -> max_strat
                                                                                                                                                         | Some x -> if x < max_strat then x else max_strat
                                                                                                                                                      end in
                                                                                                                                                    let max_strat = 
                                                                                                                                                      begin
                                                                                                                                                       match mult3 with
                                                                                                                                                       | None -> max_strat
                                                                                                                                                       | Some x -> if x < max_strat then x else max_strat
                                                                                                                                                      end in
                                                                                                                                                  
                                                                                                                                                    (* Now compute the price *)
                                                                                                                                                    let strat_price = 
                                                                                                                                                      begin 
                                                                                                                                                         match mult1 with 
                                                                                                                                                         | None -> 0
                                                                                                                                                         | Some x -> 
                                                                                                                                                           begin
                                                                                                                                                              if (adjust s.leg1.leg_mult) > 0 then
                                                                                                                                                                  match books.book1.bid_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg1.leg_mult)
                                                                                                                                                                  | None -> 0
                                                                                                                                                              else
                                                                                                                                                                  match books.book1.ask_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg1.leg_mult)
                                                                                                                                                                  | None -> 0
                                                                                                                                                           end
                                                                                                                                                      end in
                                                                                                                                                    let strat_price = 
                                                                                                                                                      begin 
                                                                                                                                                         match mult2 with 
                                                                                                                                                         | None -> strat_price
                                                                                                                                                         | Some x -> 
                                                                                                                                                           begin
                                                                                                                                                              if (adjust s.leg2.leg_mult) > 0 then
                                                                                                                                                                  match books.book2.bid_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg2.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                              else
                                                                                                                                                                  match books.book2.ask_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg2.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                           end
                                                                                                                                                      end in
                                                                                                                                                    let strat_price = 
                                                                                                                                                      begin 
                                                                                                                                                         match mult3 with 
                                                                                                                                                         | None -> strat_price
                                                                                                                                                         | Some x -> 
                                                                                                                                                           begin
                                                                                                                                                              if (adjust s.leg3.leg_mult) > 0 then
                                                                                                                                                                  match books.book3.bid_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg3.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                              else
                                                                                                                                                                  match books.book3.ask_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg3.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                           end
                                                                                                                                                      end in
                                                                                                                                                  
                                                                                                                                                    (* Now form the new implied order here... *)
                                                                                                                                                    {
                                                                                                                                                     o_qty = max_strat
                                                                                                                                                     ; o_price = strat_price
                                                                                                                                                     ; o_id = -1
                                                                                                                                                     ; o_time = time
                                                                                                                                                     ; o_side = si
                                                                                                                                                     ; o_client_id = -1
                                                                                                                                                     ; o_inst = Strategy sid
                                                                                                                                                     ; o_is_implied = true }
                                                                                                                                                  ;;
                                                                                                                                                  
                                                                                                                                                  Out[16]:
                                                                                                                                                  val get_level_sums : order list -> level_info option -> level_info option =
                                                                                                                                                    <fun>
                                                                                                                                                  val get_book_tops : book -> best_bid_ask = <fun>
                                                                                                                                                  val calc_implied_strat_order :
                                                                                                                                                    strategy_id -> strategy -> books_info -> side -> int -> order = <fun>
                                                                                                                                                  
                                                                                                                                                  termination proof

                                                                                                                                                  Termination proof

                                                                                                                                                  call `get_level_sums (List.tl orders) (Some {li_qty = (List.hd orders).o_qty; li_price = (List.hd orders).o_price})` from `get_level_sums orders li`
                                                                                                                                                  originalget_level_sums orders li
                                                                                                                                                  subget_level_sums (List.tl orders) (Some {li_qty = (List.hd orders).o_qty; li_price = (List.hd orders).o_price})
                                                                                                                                                  original ordinalOrdinal.Int (Ordinal.count orders)
                                                                                                                                                  sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                                                                                                                                  path[li = None && not (orders = [])]
                                                                                                                                                  proof
                                                                                                                                                  detailed proof
                                                                                                                                                  ground_instances3
                                                                                                                                                  definitions0
                                                                                                                                                  inductions0
                                                                                                                                                  search_time
                                                                                                                                                  0.017s
                                                                                                                                                  details
                                                                                                                                                  Expand
                                                                                                                                                  smt_stats
                                                                                                                                                  num checks8
                                                                                                                                                  arith-assume-eqs1
                                                                                                                                                  arith-make-feasible66
                                                                                                                                                  arith-max-columns49
                                                                                                                                                  arith-conflicts2
                                                                                                                                                  rlimit count10997
                                                                                                                                                  mk clause64
                                                                                                                                                  datatype occurs check54
                                                                                                                                                  mk bool var354
                                                                                                                                                  arith-lower33
                                                                                                                                                  datatype splits69
                                                                                                                                                  decisions94
                                                                                                                                                  propagations61
                                                                                                                                                  interface eqs1
                                                                                                                                                  arith-max-rows21
                                                                                                                                                  conflicts9
                                                                                                                                                  datatype accessor ax47
                                                                                                                                                  datatype constructor ax110
                                                                                                                                                  final checks10
                                                                                                                                                  added eqs483
                                                                                                                                                  del clause35
                                                                                                                                                  arith eq adapter31
                                                                                                                                                  arith-upper60
                                                                                                                                                  memory41.480000
                                                                                                                                                  max memory86.910000
                                                                                                                                                  num allocs8333512003.000000
                                                                                                                                                  Expand
                                                                                                                                                  • start[0.017s]
                                                                                                                                                      li = None
                                                                                                                                                      && not (orders = [])
                                                                                                                                                         && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                                                                                                                                                      ==> not
                                                                                                                                                          (Some
                                                                                                                                                           {li_qty = (List.hd orders).o_qty; li_price = (List.hd orders).o_price}
                                                                                                                                                           = None && not (List.tl orders = []))
                                                                                                                                                          && not
                                                                                                                                                             ((List.hd orders).o_price = (List.hd (List.tl orders)).o_price
                                                                                                                                                              && not
                                                                                                                                                                 (Some
                                                                                                                                                                  {li_qty = (List.hd orders).o_qty;
                                                                                                                                                                   li_price = (List.hd orders).o_price}
                                                                                                                                                                  = None)
                                                                                                                                                                 && not (List.tl orders = []))
                                                                                                                                                          || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                             (Ordinal.Int (Ordinal.count orders))
                                                                                                                                                  • simplify
                                                                                                                                                    into
                                                                                                                                                    (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                     (Ordinal.Int (Ordinal.count orders))
                                                                                                                                                     || not
                                                                                                                                                        ((List.hd orders).o_price = (List.hd (List.tl orders)).o_price
                                                                                                                                                         && not (List.tl orders = [])))
                                                                                                                                                    || not
                                                                                                                                                       (((li = None && not (orders = [])) && Ordinal.count orders >= 0)
                                                                                                                                                        && Ordinal.count (List.tl orders) >= 0)
                                                                                                                                                    expansions
                                                                                                                                                    []
                                                                                                                                                    rewrite_steps
                                                                                                                                                      forward_chaining
                                                                                                                                                      • unroll
                                                                                                                                                        expr
                                                                                                                                                        (|count_`order list`_2998| orders_2985)
                                                                                                                                                        expansions
                                                                                                                                                        • unroll
                                                                                                                                                          expr
                                                                                                                                                          (|count_`order list`_2998| (|get.::.1_2981| orders_2985))
                                                                                                                                                          expansions
                                                                                                                                                          • unroll
                                                                                                                                                            expr
                                                                                                                                                            (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2998|
                                                                                                                                                                                                 …
                                                                                                                                                            expansions
                                                                                                                                                            • unsat
                                                                                                                                                              (let ((a!1 (ite (>= (o_qty_50 (|get.::.0_2980| orders_2985)) 0)
                                                                                                                                                                              (o_qty_50 (|get.::.0…

                                                                                                                                                            call `get_level_sums (List.tl orders) (Some {Option.get li with li_qty = (Option.get li).li_qty + (List.hd orders).o_qty})` from `get_level_sums orders li`
                                                                                                                                                            originalget_level_sums orders li
                                                                                                                                                            subget_level_sums (List.tl orders) (Some {Option.get li with li_qty = (Option.get li).li_qty + (List.hd orders).o_qty})
                                                                                                                                                            original ordinalOrdinal.Int (Ordinal.count orders)
                                                                                                                                                            sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                                                                                                                                            path[(Option.get li).li_price = (List.hd orders).o_price && not (li = None) && not (orders = [])]
                                                                                                                                                            proof
                                                                                                                                                            detailed proof
                                                                                                                                                            ground_instances3
                                                                                                                                                            definitions0
                                                                                                                                                            inductions0
                                                                                                                                                            search_time
                                                                                                                                                            0.022s
                                                                                                                                                            details
                                                                                                                                                            Expand
                                                                                                                                                            smt_stats
                                                                                                                                                            num checks8
                                                                                                                                                            arith-assume-eqs1
                                                                                                                                                            arith-make-feasible63
                                                                                                                                                            arith-max-columns49
                                                                                                                                                            arith-conflicts2
                                                                                                                                                            rlimit count5631
                                                                                                                                                            mk clause62
                                                                                                                                                            datatype occurs check71
                                                                                                                                                            mk bool var387
                                                                                                                                                            arith-lower31
                                                                                                                                                            datatype splits78
                                                                                                                                                            decisions100
                                                                                                                                                            propagations63
                                                                                                                                                            interface eqs1
                                                                                                                                                            arith-max-rows21
                                                                                                                                                            conflicts10
                                                                                                                                                            datatype accessor ax55
                                                                                                                                                            datatype constructor ax129
                                                                                                                                                            final checks11
                                                                                                                                                            added eqs544
                                                                                                                                                            del clause33
                                                                                                                                                            arith eq adapter29
                                                                                                                                                            arith-upper56
                                                                                                                                                            memory38.790000
                                                                                                                                                            max memory86.910000
                                                                                                                                                            num allocs8240278319.000000
                                                                                                                                                            Expand
                                                                                                                                                            • start[0.022s]
                                                                                                                                                                (Option.get li).li_price = (List.hd orders).o_price
                                                                                                                                                                && not (li = None)
                                                                                                                                                                   && not (orders = [])
                                                                                                                                                                      && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                                                                                                                                                                ==> not
                                                                                                                                                                    (Some
                                                                                                                                                                     {li_qty = (Option.get li).li_qty + (List.hd orders).o_qty;
                                                                                                                                                                      li_price = (Option.get li).li_price}
                                                                                                                                                                     = None && not (List.tl orders = []))
                                                                                                                                                                    && not
                                                                                                                                                                       ((Option.get li).li_price = (List.hd (List.tl orders)).o_price
                                                                                                                                                                        && not
                                                                                                                                                                           (Some
                                                                                                                                                                            {li_qty = (Option.get li).li_qty + (List.hd orders).o_qty;
                                                                                                                                                                             li_price = (Option.get li).li_price}
                                                                                                                                                                            = None)
                                                                                                                                                                           && not (List.tl orders = []))
                                                                                                                                                                    || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                                       (Ordinal.Int (Ordinal.count orders))
                                                                                                                                                            • simplify
                                                                                                                                                              into
                                                                                                                                                              (Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                               (Ordinal.Int (Ordinal.count orders))
                                                                                                                                                               || not
                                                                                                                                                                  ((Option.get li).li_price = (List.hd (List.tl orders)).o_price
                                                                                                                                                                   && not (List.tl orders = [])))
                                                                                                                                                              || not
                                                                                                                                                                 (((((Option.get li).li_price = (List.hd orders).o_price && not (li = None))
                                                                                                                                                                    && not (orders = []))
                                                                                                                                                                   && Ordinal.count orders >= 0)
                                                                                                                                                                  && Ordinal.count (List.tl orders) >= 0)
                                                                                                                                                              expansions
                                                                                                                                                              []
                                                                                                                                                              rewrite_steps
                                                                                                                                                                forward_chaining
                                                                                                                                                                • unroll
                                                                                                                                                                  expr
                                                                                                                                                                  (|count_`order list`_2998| orders_2985)
                                                                                                                                                                  expansions
                                                                                                                                                                  • unroll
                                                                                                                                                                    expr
                                                                                                                                                                    (|count_`order list`_2998| (|get.::.1_2981| orders_2985))
                                                                                                                                                                    expansions
                                                                                                                                                                    • unroll
                                                                                                                                                                      expr
                                                                                                                                                                      (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_2998|
                                                                                                                                                                                                           …
                                                                                                                                                                      expansions
                                                                                                                                                                      • unsat
                                                                                                                                                                        (let ((a!1 (ite (>= (li_price_41 (|get.Some.0_2984| li_2986)) 0)
                                                                                                                                                                                        (li_price_41 (|get.…

                                                                                                                                                                      Let's now try to experiment with this.

                                                                                                                                                                      In [17]:
                                                                                                                                                                      let strat1 = {
                                                                                                                                                                        time_created = 1;
                                                                                                                                                                        leg1    = { leg_sec_idx = OUT1; leg_mult = 1 }
                                                                                                                                                                        ; leg2  = { leg_sec_idx = OUT2; leg_mult = 0 }
                                                                                                                                                                        ; leg3  = { leg_sec_idx = OUT3; leg_mult = 0 }
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      let books = {
                                                                                                                                                                          book1 = { bid_info = None ; ask_info = Some { li_qty = 100 ; li_price = 450 }}
                                                                                                                                                                        ; book2 = { bid_info = Some { li_qty = 125 ; li_price = 100 }; ask_info = Some { li_qty = 100 ; li_price = 350 }}
                                                                                                                                                                        ; book3 = { bid_info = None ; ask_info = Some { li_qty = 100 ; li_price = 425 }} 
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      (* This should just replicate the OUT1 security on the SELL side *)
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat1 books SELL 1
                                                                                                                                                                      
                                                                                                                                                                      Out[17]:
                                                                                                                                                                      val strat1 : strategy =
                                                                                                                                                                        {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                         leg2 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                                         leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                      val books : books_info =
                                                                                                                                                                        {book1 = {bid_info = None; ask_info = Some {li_qty = 100; li_price = 450}};
                                                                                                                                                                         book2 =
                                                                                                                                                                          {bid_info = Some {li_qty = 125; li_price = 100};
                                                                                                                                                                           ask_info = Some {li_qty = 100; li_price = 350}};
                                                                                                                                                                         book3 = {bid_info = None; ask_info = Some {li_qty = 100; li_price = 425}}}
                                                                                                                                                                      - : order = <document>
                                                                                                                                                                      
                                                                                                                                                                      -450 (100)
                                                                                                                                                                      Implied
                                                                                                                                                                      In [18]:
                                                                                                                                                                      (* Now let's try the same on the BUY side - there should not be any available orders as the bid is empty *)
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat1 books BUY 1
                                                                                                                                                                      
                                                                                                                                                                      Out[18]:
                                                                                                                                                                      - : order = <document>
                                                                                                                                                                      
                                                                                                                                                                      0 (0)
                                                                                                                                                                      Implied
                                                                                                                                                                      In [19]:
                                                                                                                                                                      (* let's try to mix up the legs now *)
                                                                                                                                                                      
                                                                                                                                                                      let strat2 = {
                                                                                                                                                                       strat1 with
                                                                                                                                                                       leg2 = {leg_sec_idx = OUT2; leg_mult = -1}
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      (* This will not result in any orders because there's no BUY *)
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat2 books BUY 1
                                                                                                                                                                      
                                                                                                                                                                      Out[19]:
                                                                                                                                                                      val strat2 : strategy =
                                                                                                                                                                        {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                         leg2 = {leg_sec_idx = OUT2; leg_mult = -1};
                                                                                                                                                                         leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                      - : order = <document>
                                                                                                                                                                      
                                                                                                                                                                      -350 (0)
                                                                                                                                                                      Implied
                                                                                                                                                                      In [20]:
                                                                                                                                                                      calc_implied_strat_order STRAT2 strat2 books SELL 1
                                                                                                                                                                      
                                                                                                                                                                      Out[20]:
                                                                                                                                                                      - : order = <document>
                                                                                                                                                                      
                                                                                                                                                                      -450 (100)
                                                                                                                                                                      Implied
                                                                                                                                                                      In [21]:
                                                                                                                                                                      let strat = {
                                                                                                                                                                        time_created = 1;
                                                                                                                                                                        leg1    = { leg_sec_idx = OUT1; leg_mult = 1 }
                                                                                                                                                                        ; leg2  = { leg_sec_idx = OUT2; leg_mult = -2 }
                                                                                                                                                                        ; leg3  = { leg_sec_idx = OUT3; leg_mult = 0 }
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      let books = {
                                                                                                                                                                          book1 = { bid_info = Some { li_qty = 500; li_price = 50 } ; ask_info = Some { li_qty = 750 ; li_price = 50 }}
                                                                                                                                                                        ; book2 = { bid_info = Some { li_qty = 200 ; li_price = 60 }; ask_info = Some { li_qty = 500 ; li_price = 70 }}
                                                                                                                                                                        ; book3 = { bid_info = None ; ask_info = None } 
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat books BUY 1
                                                                                                                                                                      
                                                                                                                                                                      Out[21]:
                                                                                                                                                                      val strat : strategy =
                                                                                                                                                                        {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                         leg2 = {leg_sec_idx = OUT2; leg_mult = -2};
                                                                                                                                                                         leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                      val books : books_info =
                                                                                                                                                                        {book1 =
                                                                                                                                                                          {bid_info = Some {li_qty = 500; li_price = 50};
                                                                                                                                                                           ask_info = Some {li_qty = 750; li_price = 50}};
                                                                                                                                                                         book2 =
                                                                                                                                                                          {bid_info = Some {li_qty = 200; li_price = 60};
                                                                                                                                                                           ask_info = Some {li_qty = 500; li_price = 70}};
                                                                                                                                                                         book3 = {bid_info = None; ask_info = None}}
                                                                                                                                                                      - : order = <document>
                                                                                                                                                                      
                                                                                                                                                                      -90 (250)
                                                                                                                                                                      Implied

                                                                                                                                                                      3.3 Implied uncrossing operations

                                                                                                                                                                      In [22]:
                                                                                                                                                                      (* removes implied orders from a book *)
                                                                                                                                                                      let remove_imp_orders (b : book) =
                                                                                                                                                                        let rec remove_imp_orders_side (orders : order list) = 
                                                                                                                                                                          match orders with
                                                                                                                                                                          | [] -> []
                                                                                                                                                                          | x::xs -> 
                                                                                                                                                                              if x.o_is_implied then 
                                                                                                                                                                                (remove_imp_orders_side xs)
                                                                                                                                                                              else
                                                                                                                                                                                x::(remove_imp_orders_side xs) in
                                                                                                                                                                          
                                                                                                                                                                        { b_buys = (remove_imp_orders_side b.b_buys)
                                                                                                                                                                        ; b_sells = (remove_imp_orders_side b.b_sells)
                                                                                                                                                                        }
                                                                                                                                                                      
                                                                                                                                                                      (* Allocate implied fills to the book and return fills *)
                                                                                                                                                                      let allocate_implied_fills (b : book) (qty : int) (price : int) (time : int) = 
                                                                                                                                                                        if qty = 0 then {
                                                                                                                                                                          uncrossed_book = b
                                                                                                                                                                          ; uncrossed_fills = []
                                                                                                                                                                          ; uncrossed_qty = 0
                                                                                                                                                                        } else 
                                                                                                                                                                        begin
                                                                                                                                                                          (* Insert new order into the book and uncross it *)
                                                                                                                                                                          let new_order = {
                                                                                                                                                                            o_qty = if qty < 0 then (-qty) else qty
                                                                                                                                                                            ; o_price = price
                                                                                                                                                                            ; o_id = -1
                                                                                                                                                                            ; o_time = time
                                                                                                                                                                            ; o_side = if qty < 0 then SELL else BUY
                                                                                                                                                                            ; o_client_id = -1
                                                                                                                                                                            ; o_inst = Outright OUT1
                                                                                                                                                                            ; o_is_implied = true
                                                                                                                                                                          } in 
                                                                                                                                                                          
                                                                                                                                                                          (* create new order that we will trade *)
                                                                                                                                                                          let b' = insert_order new_order b in
                                                                                                                                                                      
                                                                                                                                                                          (* finally we will uncross the book and return results *)
                                                                                                                                                                          (uncross_book b' [] 0)
                                                                                                                                                                        end
                                                                                                                                                                      
                                                                                                                                                                      (* Calculate the price at which implied orders should trade in the outright books *)
                                                                                                                                                                      let calc_implied_trade_price (mult : int) (bidask : best_bid_ask) =
                                                                                                                                                                        if mult > 0 then
                                                                                                                                                                         begin
                                                                                                                                                                          match bidask.ask_info with
                                                                                                                                                                            | None -> 0
                                                                                                                                                                            | Some x -> x.li_price
                                                                                                                                                                          end
                                                                                                                                                                        else
                                                                                                                                                                          begin
                                                                                                                                                                              match bidask.bid_info with
                                                                                                                                                                                | None -> 0
                                                                                                                                                                                | Some x -> x.li_price
                                                                                                                                                                          end
                                                                                                                                                                      ;;
                                                                                                                                                                      
                                                                                                                                                                      Out[22]:
                                                                                                                                                                      val remove_imp_orders : book -> book = <fun>
                                                                                                                                                                      val allocate_implied_fills : book -> int -> int -> int -> uncross_res = <fun>
                                                                                                                                                                      val calc_implied_trade_price : int -> best_bid_ask -> int = <fun>
                                                                                                                                                                      
                                                                                                                                                                      termination proof

                                                                                                                                                                      Termination proof

                                                                                                                                                                      call `recfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)` from `recfun.remove_imp_orders.remove_imp_orders_side.0 orders`
                                                                                                                                                                      originalrecfun.remove_imp_orders.remove_imp_orders_side.0 orders
                                                                                                                                                                      subrecfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)
                                                                                                                                                                      original ordinalOrdinal.Int (Ordinal.count orders)
                                                                                                                                                                      sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                                                                                                                                                      path[(List.hd orders).o_is_implied && not (orders = [])]
                                                                                                                                                                      proof
                                                                                                                                                                      detailed proof
                                                                                                                                                                      ground_instances3
                                                                                                                                                                      definitions0
                                                                                                                                                                      inductions0
                                                                                                                                                                      search_time
                                                                                                                                                                      0.017s
                                                                                                                                                                      details
                                                                                                                                                                      Expand
                                                                                                                                                                      smt_stats
                                                                                                                                                                      num checks8
                                                                                                                                                                      arith-assume-eqs1
                                                                                                                                                                      arith-make-feasible76
                                                                                                                                                                      arith-max-columns52
                                                                                                                                                                      arith-conflicts2
                                                                                                                                                                      rlimit count11124
                                                                                                                                                                      mk clause87
                                                                                                                                                                      datatype occurs check50
                                                                                                                                                                      mk bool var369
                                                                                                                                                                      arith-lower40
                                                                                                                                                                      datatype splits61
                                                                                                                                                                      decisions95
                                                                                                                                                                      propagations92
                                                                                                                                                                      interface eqs1
                                                                                                                                                                      arith-max-rows22
                                                                                                                                                                      conflicts11
                                                                                                                                                                      datatype accessor ax44
                                                                                                                                                                      datatype constructor ax107
                                                                                                                                                                      final checks11
                                                                                                                                                                      added eqs469
                                                                                                                                                                      del clause45
                                                                                                                                                                      arith eq adapter38
                                                                                                                                                                      arith-upper70
                                                                                                                                                                      memory29.140000
                                                                                                                                                                      max memory86.910000
                                                                                                                                                                      num allocs9264161525.000000
                                                                                                                                                                      Expand
                                                                                                                                                                      • start[0.017s]
                                                                                                                                                                          (List.hd orders).o_is_implied
                                                                                                                                                                          && not (orders = [])
                                                                                                                                                                             && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                                                                                                                                                                          ==> not
                                                                                                                                                                              ((List.hd (List.tl orders)).o_is_implied && not (List.tl orders = []))
                                                                                                                                                                              && not
                                                                                                                                                                                 (not (List.hd (List.tl orders)).o_is_implied
                                                                                                                                                                                  && not (List.tl orders = []))
                                                                                                                                                                              || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                                                 (Ordinal.Int (Ordinal.count orders))
                                                                                                                                                                      • simplify
                                                                                                                                                                        into
                                                                                                                                                                        (not ((List.hd (List.tl orders)).o_is_implied && not (List.tl orders = []))
                                                                                                                                                                         && not
                                                                                                                                                                            (not (List.hd (List.tl orders)).o_is_implied && not (List.tl orders = []))
                                                                                                                                                                         || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                                            (Ordinal.Int (Ordinal.count orders)))
                                                                                                                                                                        || not
                                                                                                                                                                           ((((List.hd orders).o_is_implied && not (orders = []))
                                                                                                                                                                             && Ordinal.count orders >= 0)
                                                                                                                                                                            && Ordinal.count (List.tl orders) >= 0)
                                                                                                                                                                        expansions
                                                                                                                                                                        []
                                                                                                                                                                        rewrite_steps
                                                                                                                                                                          forward_chaining
                                                                                                                                                                          • unroll
                                                                                                                                                                            expr
                                                                                                                                                                            (|count_`order list`_3090| orders_3079)
                                                                                                                                                                            expansions
                                                                                                                                                                            • unroll
                                                                                                                                                                              expr
                                                                                                                                                                              (|count_`order list`_3090| (|get.::.1_3078| orders_3079))
                                                                                                                                                                              expansions
                                                                                                                                                                              • unroll
                                                                                                                                                                                expr
                                                                                                                                                                                (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_3090|
                                                                                                                                                                                                                     …
                                                                                                                                                                                expansions
                                                                                                                                                                                • unsat
                                                                                                                                                                                  (let ((a!1 (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_3090|
                                                                                                                                                                                                            …

                                                                                                                                                                                call `recfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)` from `recfun.remove_imp_orders.remove_imp_orders_side.0 orders`
                                                                                                                                                                                originalrecfun.remove_imp_orders.remove_imp_orders_side.0 orders
                                                                                                                                                                                subrecfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)
                                                                                                                                                                                original ordinalOrdinal.Int (Ordinal.count orders)
                                                                                                                                                                                sub ordinalOrdinal.Int (Ordinal.count (List.tl orders))
                                                                                                                                                                                path[not (List.hd orders).o_is_implied && not (orders = [])]
                                                                                                                                                                                proof
                                                                                                                                                                                detailed proof
                                                                                                                                                                                ground_instances3
                                                                                                                                                                                definitions0
                                                                                                                                                                                inductions0
                                                                                                                                                                                search_time
                                                                                                                                                                                0.017s
                                                                                                                                                                                details
                                                                                                                                                                                Expand
                                                                                                                                                                                smt_stats
                                                                                                                                                                                num checks8
                                                                                                                                                                                arith-assume-eqs1
                                                                                                                                                                                arith-make-feasible78
                                                                                                                                                                                arith-max-columns52
                                                                                                                                                                                arith-conflicts2
                                                                                                                                                                                rlimit count5613
                                                                                                                                                                                mk clause88
                                                                                                                                                                                datatype occurs check50
                                                                                                                                                                                mk bool var371
                                                                                                                                                                                arith-lower41
                                                                                                                                                                                datatype splits61
                                                                                                                                                                                decisions97
                                                                                                                                                                                propagations96
                                                                                                                                                                                interface eqs1
                                                                                                                                                                                arith-max-rows22
                                                                                                                                                                                conflicts11
                                                                                                                                                                                datatype accessor ax44
                                                                                                                                                                                datatype constructor ax107
                                                                                                                                                                                final checks11
                                                                                                                                                                                added eqs473
                                                                                                                                                                                del clause46
                                                                                                                                                                                arith eq adapter39
                                                                                                                                                                                arith-upper72
                                                                                                                                                                                memory26.380000
                                                                                                                                                                                max memory86.910000
                                                                                                                                                                                num allocs9168346868.000000
                                                                                                                                                                                Expand
                                                                                                                                                                                • start[0.017s]
                                                                                                                                                                                    not (List.hd orders).o_is_implied
                                                                                                                                                                                    && not (orders = [])
                                                                                                                                                                                       && Ordinal.count orders >= 0 && Ordinal.count (List.tl orders) >= 0
                                                                                                                                                                                    ==> not
                                                                                                                                                                                        ((List.hd (List.tl orders)).o_is_implied && not (List.tl orders = []))
                                                                                                                                                                                        && not
                                                                                                                                                                                           (not (List.hd (List.tl orders)).o_is_implied
                                                                                                                                                                                            && not (List.tl orders = []))
                                                                                                                                                                                        || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                                                           (Ordinal.Int (Ordinal.count orders))
                                                                                                                                                                                • simplify
                                                                                                                                                                                  into
                                                                                                                                                                                  (not ((List.hd (List.tl orders)).o_is_implied && not (List.tl orders = []))
                                                                                                                                                                                   && not
                                                                                                                                                                                      (not (List.hd (List.tl orders)).o_is_implied && not (List.tl orders = []))
                                                                                                                                                                                   || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl orders)))
                                                                                                                                                                                      (Ordinal.Int (Ordinal.count orders)))
                                                                                                                                                                                  || not
                                                                                                                                                                                     (((not (List.hd orders).o_is_implied && not (orders = []))
                                                                                                                                                                                       && Ordinal.count orders >= 0)
                                                                                                                                                                                      && Ordinal.count (List.tl orders) >= 0)
                                                                                                                                                                                  expansions
                                                                                                                                                                                  []
                                                                                                                                                                                  rewrite_steps
                                                                                                                                                                                    forward_chaining
                                                                                                                                                                                    • unroll
                                                                                                                                                                                      expr
                                                                                                                                                                                      (|count_`order list`_3090| orders_3079)
                                                                                                                                                                                      expansions
                                                                                                                                                                                      • unroll
                                                                                                                                                                                        expr
                                                                                                                                                                                        (|count_`order list`_3090| (|get.::.1_3078| orders_3079))
                                                                                                                                                                                        expansions
                                                                                                                                                                                        • unroll
                                                                                                                                                                                          expr
                                                                                                                                                                                          (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_3090|
                                                                                                                                                                                                                               …
                                                                                                                                                                                          expansions
                                                                                                                                                                                          • unsat
                                                                                                                                                                                            (let ((a!1 (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`order list`_3090|
                                                                                                                                                                                                                      …

                                                                                                                                                                                          3.4 Implied uncrossing (for single side)

                                                                                                                                                                                          In [23]:
                                                                                                                                                                                          (* The actual cycle *)
                                                                                                                                                                                          let implied_uncross_side (sd : side) (s_id : strategy_id) (s : strategy) (m : market) =
                                                                                                                                                                                          
                                                                                                                                                                                            (* 0. get the top of the book s*)
                                                                                                                                                                                            let book1 = get_book_tops m.out_book1 in
                                                                                                                                                                                            let book2 = get_book_tops m.out_book2 in
                                                                                                                                                                                            let book3 = get_book_tops m.out_book3 in 
                                                                                                                                                                                          
                                                                                                                                                                                            let books_tops = { book1; book2; book3 } in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 1. calculate the implied orders that are available right now... *)
                                                                                                                                                                                            let imp_order = calc_implied_strat_order s_id s books_tops sd m.curr_time in
                                                                                                                                                                                          
                                                                                                                                                                                            (* Need to increase the order ID first *)
                                                                                                                                                                                            let new_ord_id = m.last_ord_id + 1 in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 2. insert them into the order book *)
                                                                                                                                                                                            let strat_book =
                                                                                                                                                                                              begin
                                                                                                                                                                                                match s_id with
                                                                                                                                                                                                | STRAT1 -> insert_order { imp_order with o_id = new_ord_id } m.s_book1
                                                                                                                                                                                                | STRAT2 -> insert_order { imp_order with o_id = new_ord_id } m.s_book2
                                                                                                                                                                                              end in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 3. perform the uncross - get the fills, etc... *)
                                                                                                                                                                                            let unc_result = uncross_book strat_book [] 0 in
                                                                                                                                                                                          
                                                                                                                                                                                            let fq = unc_result.uncrossed_qty in
                                                                                                                                                                                          
                                                                                                                                                                                            if fq = 0 then
                                                                                                                                                                                              (* Since we didn't trade anything, let's just return the original market state *)
                                                                                                                                                                                              m
                                                                                                                                                                                            else
                                                                                                                                                                                            
                                                                                                                                                                                            let adjust (mult : int) =
                                                                                                                                                                                              let mult = -mult in
                                                                                                                                                                                              if sd = BUY then mult else -mult in
                                                                                                                                                                                            
                                                                                                                                                                                            let adj_mul1 = adjust s.leg1.leg_mult in
                                                                                                                                                                                            let adj_mul2 = adjust s.leg2.leg_mult in
                                                                                                                                                                                            let adj_mul3 = adjust s.leg3.leg_mult in
                                                                                                                                                                                            
                                                                                                                                                                                            (* calculate the prices at which outright orders will trade *)
                                                                                                                                                                                            let price1 = calc_implied_trade_price adj_mul1 book1 in
                                                                                                                                                                                            let price2 = calc_implied_trade_price adj_mul2 book2 in
                                                                                                                                                                                            let price3 = calc_implied_trade_price adj_mul3 book3 in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 4. allocate fills to the outright orders *)
                                                                                                                                                                                            let out_book1_res = allocate_implied_fills m.out_book1 (fq * adj_mul1) price1 m.curr_time in
                                                                                                                                                                                            let out_book2_res = allocate_implied_fills m.out_book2 (fq * adj_mul2) price2 m.curr_time in
                                                                                                                                                                                            let out_book3_res = allocate_implied_fills m.out_book3 (fq * adj_mul3) price3 m.curr_time in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 5. remove the implied orders - notice that the uncrossed result contains a new book
                                                                                                                                                                                              with partial fills *)
                                                                                                                                                                                            let m = match s_id with
                                                                                                                                                                                            | STRAT1 -> { m with s_book1 = remove_imp_orders unc_result.uncrossed_book }
                                                                                                                                                                                            | STRAT2 -> { m with s_book2 = remove_imp_orders unc_result.uncrossed_book } in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 6. let's now gather all of the fills and turn them into outbound messages *)
                                                                                                                                                                                            let new_fill_msgs = create_fill_msgs (unc_result.uncrossed_fills @ out_book1_res.uncrossed_fills
                                                                                                                                                                                              @ out_book2_res.uncrossed_fills @ out_book3_res.uncrossed_fills) in
                                                                                                                                                                                          
                                                                                                                                                                                            { m with 
                                                                                                                                                                                              outbound_msgs = new_fill_msgs @ m.outbound_msgs
                                                                                                                                                                                              ; out_book1 = out_book1_res.uncrossed_book
                                                                                                                                                                                              ; out_book2 = out_book2_res.uncrossed_book
                                                                                                                                                                                              ; out_book3 = out_book3_res.uncrossed_book
                                                                                                                                                                                              ; last_ord_id = new_ord_id }
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[23]:
                                                                                                                                                                                          val implied_uncross_side :
                                                                                                                                                                                            side -> strategy_id -> strategy -> market -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          Let's now experiment with some concrete examples.

                                                                                                                                                                                          In [24]:
                                                                                                                                                                                          #program;;
                                                                                                                                                                                          (* #remove_doc doc_of_market;; *)
                                                                                                                                                                                          #logic;;
                                                                                                                                                                                          
                                                                                                                                                                                          let strat = {
                                                                                                                                                                                            time_created = 1;
                                                                                                                                                                                            leg1    = { leg_sec_idx = OUT1; leg_mult = 1 }
                                                                                                                                                                                            ; leg2  = { leg_sec_idx = OUT2; leg_mult = -2 }
                                                                                                                                                                                            ; leg3  = { leg_sec_idx = OUT3; leg_mult = 0 }
                                                                                                                                                                                          };;
                                                                                                                                                                                          
                                                                                                                                                                                          let books = {
                                                                                                                                                                                              book1 = { bid_info = Some { li_qty = 500; li_price = 50 } ; ask_info = Some { li_qty = 750 ; li_price = 50 }}
                                                                                                                                                                                            ; book2 = { bid_info = Some { li_qty = 200 ; li_price = 60 }; ask_info = Some { li_qty = 500 ; li_price = 70 }}
                                                                                                                                                                                            ; book3 = { bid_info = None ; ask_info = None } 
                                                                                                                                                                                          };;
                                                                                                                                                                                          
                                                                                                                                                                                          let m = {
                                                                                                                                                                                            curr_time = 1
                                                                                                                                                                                            
                                                                                                                                                                                            ; last_ord_id = 0
                                                                                                                                                                                          
                                                                                                                                                                                            (* first strategy is 2*x1 - x2 + x3 *)
                                                                                                                                                                                            ; strat1 = (make_strat 1 2 (-1) 1)
                                                                                                                                                                                            (* second strategy is just the 3rd outright security *)
                                                                                                                                                                                            ; strat2 = (make_strat 2 0 1 0)
                                                                                                                                                                                          
                                                                                                                                                                                            (* outright books *)
                                                                                                                                                                                            ; out_book1 = { 
                                                                                                                                                                                              b_buys = [ (make BUY 500 50 1 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 750 55 2 (Outright OUT1) 1 false 1) ] 
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            ; out_book2 = {
                                                                                                                                                                                              b_buys = [ (make BUY 200 60 3 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 500 70 4 (Outright OUT1) 1 false 1) ] 
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            ; out_book3 = { 
                                                                                                                                                                                              b_buys = [ ]
                                                                                                                                                                                              ; b_sells = [] 
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            (* Strategy books *)
                                                                                                                                                                                            ; s_book1 = { 
                                                                                                                                                                                              b_buys = [ 
                                                                                                                                                                                              ]
                                                                                                                                                                                              ; b_sells = [
                                                                                                                                                                                                (make SELL 100 (-100) 5 (Strategy STRAT1) 1 false 1)
                                                                                                                                                                                              ] 
                                                                                                                                                                                            }
                                                                                                                                                                                            ; s_book2 = empty_book
                                                                                                                                                                                          
                                                                                                                                                                                            (* Inbound and outbound message queues *)
                                                                                                                                                                                            ; inbound_msgs = [] 
                                                                                                                                                                                            ; outbound_msgs = []
                                                                                                                                                                                          } in
                                                                                                                                                                                          
                                                                                                                                                                                          let m' = implied_uncross_side BUY STRAT1 strat m in
                                                                                                                                                                                          
                                                                                                                                                                                          (*calc_implied_strat_order STRAT1 m.strat1 books BUY 1 *)
                                                                                                                                                                                          m'.outbound_msgs
                                                                                                                                                                                          
                                                                                                                                                                                          Out[24]:
                                                                                                                                                                                          val strat : strategy =
                                                                                                                                                                                            {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                                             leg2 = {leg_sec_idx = OUT2; leg_mult = -2};
                                                                                                                                                                                             leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                                          val books : books_info =
                                                                                                                                                                                            {book1 =
                                                                                                                                                                                              {bid_info = Some {li_qty = 500; li_price = 50};
                                                                                                                                                                                               ask_info = Some {li_qty = 750; li_price = 50}};
                                                                                                                                                                                             book2 =
                                                                                                                                                                                              {bid_info = Some {li_qty = 200; li_price = 60};
                                                                                                                                                                                               ask_info = Some {li_qty = 500; li_price = 70}};
                                                                                                                                                                                             book3 = {bid_info = None; ask_info = None}}
                                                                                                                                                                                          - : outbound_msg list =
                                                                                                                                                                                          [Fill
                                                                                                                                                                                            {fill_client_id = 1; fill_qty = 100; fill_price = -95; fill_order_id = 5;
                                                                                                                                                                                             fill_order_done = true};
                                                                                                                                                                                           Fill
                                                                                                                                                                                            {fill_client_id = 1; fill_qty = 100; fill_price = 50; fill_order_id = 1;
                                                                                                                                                                                             fill_order_done = true};
                                                                                                                                                                                           Fill
                                                                                                                                                                                            {fill_client_id = 1; fill_qty = 200; fill_price = 70; fill_order_id = 4;
                                                                                                                                                                                             fill_order_done = true}]
                                                                                                                                                                                          

                                                                                                                                                                                          3.5 Implied uncrossing decomposition

                                                                                                                                                                                          In [25]:
                                                                                                                                                                                          (* Let's try to decompose the logic of 'implied_uncross_side' - we will put 
                                                                                                                                                                                             several functions in the basis to focus on the critical aspects of the logic *)
                                                                                                                                                                                          let d = Modular_decomp.top "implied_uncross_side" 
                                                                                                                                                                                                  ~basis:["get_book_tops"; "allocate_implied_fills"; "insert_order";
                                                                                                                                                                                                  "create_fill_msgs"; "calc_implied_strat_order"] ~prune:true [@@program];;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[25]:
                                                                                                                                                                                          val d : Top_result.modular_decomposition =
                                                                                                                                                                                            {Imandra_interactive.Modular_decomp.MD.md_session = 2i;
                                                                                                                                                                                             md_f =
                                                                                                                                                                                              {Imandra_surface.Uid.name = "implied_uncross_side"; id = <abstr>;
                                                                                                                                                                                               special_tag = <abstr>; namespace = <abstr>;
                                                                                                                                                                                               chash = Some i999QKwAeBUZQbWwuOTJecHwOnUpVaAyCUgRu6mGDFY;
                                                                                                                                                                                               depth = (6i, 8i)};
                                                                                                                                                                                             md_args =
                                                                                                                                                                                              [(sd : side); (s_id : strategy_id); (s : strategy); (m : market)];
                                                                                                                                                                                             md_regions = <abstr>}
                                                                                                                                                                                          
                                                                                                                                                                                          Regions details

                                                                                                                                                                                          No group selected.

                                                                                                                                                                                          • Concrete regions are numbered
                                                                                                                                                                                          • Unnumbered regions are groups whose children share a particular constraint
                                                                                                                                                                                          • Click on a region to view its details
                                                                                                                                                                                          • Double click on a region to zoom in on it
                                                                                                                                                                                          • Shift+double click to zoom out
                                                                                                                                                                                          • Hit escape to reset back to the top
                                                                                                                                                                                          decomp of (implied_uncross_side sd, s_id, s, m
                                                                                                                                                                                          Reg_idConstraintsInvariant
                                                                                                                                                                                          257
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          256
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          255
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          254
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          253
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          252
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          251
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          250
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          249
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          248
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          247
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          246
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          245
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          244
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          243
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          242
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          241
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          240
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          239
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          238
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          237
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          236
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          235
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          234
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          233
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          232
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          231
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          230
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          229
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          228
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          227
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          226
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          225
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          224
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          223
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          222
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          221
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          220
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          219
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          218
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          217
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          216
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          215
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          214
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          213
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          212
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          211
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          210
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          209
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          208
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          207
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          206
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          205
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          204
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          203
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          202
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          201
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          200
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          199
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          198
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          197
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          196
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          195
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          194
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          193
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          192
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          191
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          190
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          189
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          188
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          187
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          186
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          185
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          184
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          183
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          182
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          181
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          180
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          179
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          178
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          177
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          176
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          175
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          174
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          173
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          172
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          171
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          170
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          169
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          168
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          167
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          166
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          165
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          164
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          163
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          162
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          161
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          160
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          159
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          158
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          157
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          156
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          155
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          154
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          153
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          152
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          151
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          150
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          149
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          148
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          147
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          146
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          145
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          144
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          143
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          142
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          141
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          140
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          139
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          138
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          137
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          136
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          135
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          134
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          133
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          132
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          131
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          130
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          129
                                                                                                                                                                                          • (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            = 0
                                                                                                                                                                                          • not (s_id = STRAT1)
                                                                                                                                                                                          m
                                                                                                                                                                                          128
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          127
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          126
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          125
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          124
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          123
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          122
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          121
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          120
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          119
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          118
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          117
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          116
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          115
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          114
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          113
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          112
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          111
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          110
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          109
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          108
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          107
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          106
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          105
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          104
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          103
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          102
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          101
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          100
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          99
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          98
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          97
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          96
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          95
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          94
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          93
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          92
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          91
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          90
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          89
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          88
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          87
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          86
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          85
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          84
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          83
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          82
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          81
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          80
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          79
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          78
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          77
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          76
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          75
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          74
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          73
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          72
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          71
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          70
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          69
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          68
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          67
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          66
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          65
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          64
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          63
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          62
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          61
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          60
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          59
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          58
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          57
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          56
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          55
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          54
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          53
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          52
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          51
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          50
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          49
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book1).ask_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          48
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          47
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          46
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          45
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          44
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          43
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          42
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          41
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          40
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          39
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          38
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          37
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          36
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          35
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          34
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          33
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).ask_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          32
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          31
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          30
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          29
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          28
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          27
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          26
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          25
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          24
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          23
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          22
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          21
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          20
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          19
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          18
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          17
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book1).bid_info = None
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              0 m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          16
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          15
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          14
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          13
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book2).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          12
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          11
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          10
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          9
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).ask_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          8
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          7
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          6
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          5
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book2).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          4
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • (get_book_tops m.out_book3).ask_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          3
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).ask_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).ask_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          2
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • (get_book_tops m.out_book3).bid_info = None
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           0 m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               0 m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          1
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book3).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book2).bid_info = None)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not ((get_book_tops m.out_book1).bid_info = None)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = m.last_ord_id + 1;
                                                                                                                                                                                          out_book1 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book1
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg1.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book2 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book2
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg2.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          out_book3 =
                                                                                                                                                                                          (allocate_implied_fills m.out_book3
                                                                                                                                                                                           ((uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            * ~- s.leg3.leg_mult)
                                                                                                                                                                                           (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_buys;
                                                                                                                                                                                           b_sells =
                                                                                                                                                                                           recfun.remove_imp_orders.remove_imp_orders_side.0
                                                                                                                                                                                           (uncross_book
                                                                                                                                                                                            (insert_order
                                                                                                                                                                                             {calc_implied_strat_order s_id s
                                                                                                                                                                                              {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                               book3 = get_book_tops m.out_book3}
                                                                                                                                                                                              sd m.curr_time
                                                                                                                                                                                             with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                            [] 0).uncrossed_book.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append
                                                                                                                                                                                            (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_fills
                                                                                                                                                                                            (List.append
                                                                                                                                                                                             (allocate_implied_fills m.out_book1
                                                                                                                                                                                              ((uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                   book2 = get_book_tops m.out_book2; book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                  sd m.curr_time
                                                                                                                                                                                                 with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                [] 0).uncrossed_qty
                                                                                                                                                                                               * ~- s.leg1.leg_mult)
                                                                                                                                                                                              (Option.get (get_book_tops m.out_book1).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                             (List.append
                                                                                                                                                                                              (allocate_implied_fills m.out_book2
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg2.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book2).bid_info).li_price m.curr_time).uncrossed_fills
                                                                                                                                                                                              (allocate_implied_fills m.out_book3
                                                                                                                                                                                               ((uncross_book
                                                                                                                                                                                                 (insert_order
                                                                                                                                                                                                  {calc_implied_strat_order s_id s
                                                                                                                                                                                                   {book1 = get_book_tops m.out_book1;
                                                                                                                                                                                                    book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                    book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                   sd m.curr_time
                                                                                                                                                                                                  with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                                 [] 0).uncrossed_qty
                                                                                                                                                                                                * ~- s.leg3.leg_mult)
                                                                                                                                                                                               (Option.get (get_book_tops m.out_book3).bid_info).li_price m.curr_time).uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          0
                                                                                                                                                                                          • (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            = 0
                                                                                                                                                                                          • s_id = STRAT1
                                                                                                                                                                                          m

                                                                                                                                                                                          3.6 Full book implied uncross

                                                                                                                                                                                          In [26]:
                                                                                                                                                                                          (* The implied uncross algorithm *)
                                                                                                                                                                                          let implied_uncross_books (s : strategy_id) (m : market) =
                                                                                                                                                                                            if s = STRAT1 then
                                                                                                                                                                                              begin
                                                                                                                                                                                                let m = implied_uncross_side BUY s m.strat1 m in
                                                                                                                                                                                                implied_uncross_side SELL s m.strat1 m
                                                                                                                                                                                              end
                                                                                                                                                                                            else 
                                                                                                                                                                                              begin
                                                                                                                                                                                                let m = implied_uncross_side BUY s m.strat2 m in
                                                                                                                                                                                                implied_uncross_side SELL s m.strat2 m
                                                                                                                                                                                              end
                                                                                                                                                                                          
                                                                                                                                                                                          Out[26]:
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                val implied_uncross_books : strategy_id -> market -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          4. Global state transition functions functions

                                                                                                                                                                                          4.1 Insert order

                                                                                                                                                                                          In [27]:
                                                                                                                                                                                          (* Perform operation to create and insert a new order *)
                                                                                                                                                                                          let run_new_order (m : market) (no : new_ord_msg) =
                                                                                                                                                                                            let new_o_id = m.last_ord_id + 1 in
                                                                                                                                                                                            let o = {
                                                                                                                                                                                              o_id = new_o_id
                                                                                                                                                                                              ; o_qty = no.no_qty
                                                                                                                                                                                              ; o_price = no.no_price
                                                                                                                                                                                              ; o_time = m.curr_time
                                                                                                                                                                                              ; o_side = no.no_side
                                                                                                                                                                                              ; o_client_id = no.no_client_id
                                                                                                                                                                                              ; o_inst = no.no_inst_type
                                                                                                                                                                                              ; o_is_implied = false (* these are always outright *)
                                                                                                                                                                                            } in
                                                                                                                                                                                          
                                                                                                                                                                                            let m' = 
                                                                                                                                                                                              match no.no_inst_type with 
                                                                                                                                                                                              | Strategy STRAT1 -> { m with s_book1 = (insert_order o m.s_book1) }
                                                                                                                                                                                              | Strategy STRAT2 -> { m with s_book2 = (insert_order o m.s_book2) }
                                                                                                                                                                                              | Outright OUT1   -> { m with out_book1 = (insert_order o m.out_book1) }
                                                                                                                                                                                              | Outright OUT2   -> { m with out_book2 = (insert_order o m.out_book2) }
                                                                                                                                                                                              | Outright OUT3   -> { m with out_book3 = (insert_order o m.out_book3) }
                                                                                                                                                                                          
                                                                                                                                                                                            in { m' with last_ord_id = new_o_id }
                                                                                                                                                                                          
                                                                                                                                                                                          Out[27]:
                                                                                                                                                                                          val run_new_order : market -> new_ord_msg -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          4.2 Cancel order

                                                                                                                                                                                          In [28]:
                                                                                                                                                                                          (* Cancel an order *)
                                                                                                                                                                                          let run_cancel_order (m : market) (co : cancel_ord_msg) = 
                                                                                                                                                                                            match co.co_instrument with
                                                                                                                                                                                            | Strategy STRAT1 -> {m with s_book1 = (cancel_ord_book co m.s_book1)}
                                                                                                                                                                                            | Strategy STRAT2 -> {m with s_book2 = (cancel_ord_book co m.s_book2)}
                                                                                                                                                                                            | Outright OUT1 -> {m with out_book1 = (cancel_ord_book co m.out_book1)}
                                                                                                                                                                                            | Outright OUT2 -> {m with out_book2 = (cancel_ord_book co m.out_book2)}
                                                                                                                                                                                            | Outright OUT3 -> {m with out_book3 = (cancel_ord_book co m.out_book3)}
                                                                                                                                                                                          
                                                                                                                                                                                          Out[28]:
                                                                                                                                                                                          val run_cancel_order : market -> cancel_ord_msg -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          4.3 Run implied uncross

                                                                                                                                                                                          In [29]:
                                                                                                                                                                                          (* Perform opreation to execute new fill *)
                                                                                                                                                                                          let run_implied_uncross (m : market) = 
                                                                                                                                                                                          
                                                                                                                                                                                            (* Do the typical uncross between the strategies *)
                                                                                                                                                                                            let sbook1_res = uncross_book m.s_book1 [] 0 in
                                                                                                                                                                                            let sbook2_res = uncross_book m.s_book2 [] 0 in 
                                                                                                                                                                                          
                                                                                                                                                                                            (*  outright books  *)
                                                                                                                                                                                            let obook1_res = uncross_book m.out_book1 [] 0 in
                                                                                                                                                                                            let obook2_res = uncross_book m.out_book2 [] 0 in
                                                                                                                                                                                            let obook3_res = uncross_book m.out_book3 [] 0 in
                                                                                                                                                                                            
                                                                                                                                                                                            (* Now let's update the entire market state *)
                                                                                                                                                                                            let m' = {
                                                                                                                                                                                              m with
                                                                                                                                                                                                s_book1 = sbook1_res.uncrossed_book
                                                                                                                                                                                                ; s_book2 = sbook2_res.uncrossed_book
                                                                                                                                                                                          
                                                                                                                                                                                                ; out_book1 = obook1_res.uncrossed_book
                                                                                                                                                                                                ; out_book2 = obook2_res.uncrossed_book
                                                                                                                                                                                                ; out_book3 = obook3_res.uncrossed_book
                                                                                                                                                                                          
                                                                                                                                                                                                ; outbound_msgs = 
                                                                                                                                                                                                    create_fill_msgs (
                                                                                                                                                                                                      sbook1_res.uncrossed_fills @
                                                                                                                                                                                                      sbook2_res.uncrossed_fills @
                                                                                                                                                                                                      obook1_res.uncrossed_fills @
                                                                                                                                                                                                      obook2_res.uncrossed_fills @ 
                                                                                                                                                                                                      obook3_res.uncrossed_fills )
                                                                                                                                                                                            } in
                                                                                                                                                                                          
                                                                                                                                                                                            (* Now we should be done with uncrossing the books the old way,
                                                                                                                                                                                              let's now create implied orders here. 
                                                                                                                                                                                              Notice that we're using the priority function to determine which 
                                                                                                                                                                                              strategy order book runs first... *)
                                                                                                                                                                                            if priority_strat m'.strat1 m'.strat2 then
                                                                                                                                                                                              let m' = implied_uncross_books STRAT1 m' in
                                                                                                                                                                                              (implied_uncross_books STRAT2 m')
                                                                                                                                                                                            else
                                                                                                                                                                                              let m' = implied_uncross_books STRAT2 m' in
                                                                                                                                                                                              (implied_uncross_books STRAT1 m')
                                                                                                                                                                                          
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[29]:
                                                                                                                                                                                          val run_implied_uncross : market -> market = <fun>
                                                                                                                                                                                          
                                                                                                                                                                                          In [30]:
                                                                                                                                                                                          (* Now is a time for a full market uncross. *)
                                                                                                                                                                                          
                                                                                                                                                                                          let m2 = {
                                                                                                                                                                                            curr_time = 1
                                                                                                                                                                                            
                                                                                                                                                                                            ; last_ord_id = 0
                                                                                                                                                                                            
                                                                                                                                                                                            (* In a larger model, we can *)
                                                                                                                                                                                            (* first strategy is 2*x1 - x2 + x3 *)
                                                                                                                                                                                            ; strat1 = (make_strat 1 2 (-1) 1)
                                                                                                                                                                                            (* second strategy is just the 3rd outright security *)
                                                                                                                                                                                            ; strat2 = (make_strat 2 0 1 0)
                                                                                                                                                                                          
                                                                                                                                                                                            (* outright books *)
                                                                                                                                                                                            ; out_book1 = { 
                                                                                                                                                                                              b_buys = [ (make BUY 500 50 1 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 750 55 2 (Outright OUT1) 1 false 1) ] 
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            ; out_book2 = {
                                                                                                                                                                                              b_buys = [ (make BUY 200 60 3 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 500 70 4 (Outright OUT1) 1 false 1) ] 
                                                                                                                                                                                            }
                                                                                                                                                                                            ; out_book3 = empty_book
                                                                                                                                                                                          
                                                                                                                                                                                            (* Strategy books *)
                                                                                                                                                                                            ; s_book1 = empty_book
                                                                                                                                                                                            ; s_book2 = empty_book
                                                                                                                                                                                          
                                                                                                                                                                                            (* Inbound and outbound message queues *)
                                                                                                                                                                                            ; inbound_msgs = [] 
                                                                                                                                                                                            ; outbound_msgs = []
                                                                                                                                                                                          }
                                                                                                                                                                                          
                                                                                                                                                                                          Out[30]:
                                                                                                                                                                                          val m2 : market = <document>
                                                                                                                                                                                          
                                                                                                                                                                                          Strategy 1
                                                                                                                                                                                          BuysSells
                                                                                                                                                                                          Strategy 2
                                                                                                                                                                                          BuysSells
                                                                                                                                                                                          Book 1
                                                                                                                                                                                          BuysSells
                                                                                                                                                                                          50 (500)
                                                                                                                                                                                          55 (750)
                                                                                                                                                                                          Book 2
                                                                                                                                                                                          BuysSells
                                                                                                                                                                                          60 (200)
                                                                                                                                                                                          70 (500)
                                                                                                                                                                                          Book 3
                                                                                                                                                                                          BuysSells

                                                                                                                                                                                          4.4 Main transition function

                                                                                                                                                                                          This is where we put it all together. Note that this is a 'shortened' version of the full model - in a complete model we would allow new strategies to be created, more intricate state transitions (e.g. auctions) and much more.

                                                                                                                                                                                          In [31]:
                                                                                                                                                                                          (* The main state transition loop of the exchange state *)
                                                                                                                                                                                          let step (m : market) (msg : inbound_msg) = 
                                                                                                                                                                                           begin
                                                                                                                                                                                            match msg with
                                                                                                                                                                                            | NewOrder no -> run_new_order m no
                                                                                                                                                                                            | CancelOrder co -> run_cancel_order m co
                                                                                                                                                                                            | ImpliedUncross -> run_implied_uncross m
                                                                                                                                                                                           end
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          let rec run (m: market) (msgs : inbound_msg list) =
                                                                                                                                                                                           match msgs with
                                                                                                                                                                                           | [] -> []
                                                                                                                                                                                           | x::xs -> let m' = step m x in
                                                                                                                                                                                             m' :: (run m' xs)
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[31]:
                                                                                                                                                                                          val step : market -> inbound_msg -> market = <fun>
                                                                                                                                                                                          val run : market -> inbound_msg list -> market list = <fun>
                                                                                                                                                                                          
                                                                                                                                                                                          termination proof

                                                                                                                                                                                          Termination proof

                                                                                                                                                                                          call `run (step m (List.hd msgs)) (List.tl msgs)` from `run m msgs`
                                                                                                                                                                                          originalrun m msgs
                                                                                                                                                                                          subrun (step m (List.hd msgs)) (List.tl msgs)
                                                                                                                                                                                          original ordinalOrdinal.Int (Ordinal.count msgs)
                                                                                                                                                                                          sub ordinalOrdinal.Int (Ordinal.count (List.tl msgs))
                                                                                                                                                                                          path[not (msgs = [])]
                                                                                                                                                                                          proof
                                                                                                                                                                                          detailed proof
                                                                                                                                                                                          ground_instances3
                                                                                                                                                                                          definitions0
                                                                                                                                                                                          inductions0
                                                                                                                                                                                          search_time
                                                                                                                                                                                          0.031s
                                                                                                                                                                                          details
                                                                                                                                                                                          Expand
                                                                                                                                                                                          smt_stats
                                                                                                                                                                                          num checks7
                                                                                                                                                                                          arith-assume-eqs1
                                                                                                                                                                                          arith-make-feasible51
                                                                                                                                                                                          arith-max-columns64
                                                                                                                                                                                          arith-conflicts5
                                                                                                                                                                                          rlimit count6350
                                                                                                                                                                                          arith-cheap-eqs12
                                                                                                                                                                                          mk clause99
                                                                                                                                                                                          datatype occurs check43
                                                                                                                                                                                          mk bool var352
                                                                                                                                                                                          arith-lower42
                                                                                                                                                                                          arith-diseq7
                                                                                                                                                                                          datatype splits56
                                                                                                                                                                                          decisions125
                                                                                                                                                                                          arith-propagations5
                                                                                                                                                                                          propagations98
                                                                                                                                                                                          interface eqs1
                                                                                                                                                                                          arith-bound-propagations-cheap5
                                                                                                                                                                                          arith-max-rows28
                                                                                                                                                                                          conflicts17
                                                                                                                                                                                          datatype accessor ax40
                                                                                                                                                                                          minimized lits1
                                                                                                                                                                                          arith-bound-propagations-lp1
                                                                                                                                                                                          datatype constructor ax74
                                                                                                                                                                                          final checks9
                                                                                                                                                                                          added eqs376
                                                                                                                                                                                          del clause43
                                                                                                                                                                                          arith eq adapter38
                                                                                                                                                                                          arith-upper44
                                                                                                                                                                                          memory50.660000
                                                                                                                                                                                          max memory656.820000
                                                                                                                                                                                          num allocs1638272067900.000000
                                                                                                                                                                                          Expand
                                                                                                                                                                                          • start[0.031s]
                                                                                                                                                                                              not (msgs = [])
                                                                                                                                                                                              && Ordinal.count msgs >= 0 && Ordinal.count (List.tl msgs) >= 0
                                                                                                                                                                                              ==> List.tl msgs = []
                                                                                                                                                                                                  || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl msgs)))
                                                                                                                                                                                                     (Ordinal.Int (Ordinal.count msgs))
                                                                                                                                                                                          • simplify
                                                                                                                                                                                            into
                                                                                                                                                                                            (List.tl msgs = []
                                                                                                                                                                                             || Ordinal.( << ) (Ordinal.Int (Ordinal.count (List.tl msgs)))
                                                                                                                                                                                                (Ordinal.Int (Ordinal.count msgs)))
                                                                                                                                                                                            || not
                                                                                                                                                                                               ((not (msgs = []) && Ordinal.count msgs >= 0)
                                                                                                                                                                                                && Ordinal.count (List.tl msgs) >= 0)
                                                                                                                                                                                            expansions
                                                                                                                                                                                            []
                                                                                                                                                                                            rewrite_steps
                                                                                                                                                                                              forward_chaining
                                                                                                                                                                                              • unroll
                                                                                                                                                                                                expr
                                                                                                                                                                                                (|count_`inbound_msg list`_3772| msgs_3762)
                                                                                                                                                                                                expansions
                                                                                                                                                                                                • unroll
                                                                                                                                                                                                  expr
                                                                                                                                                                                                  (|count_`inbound_msg list`_3772| (|get.::.1_3719| msgs_3762))
                                                                                                                                                                                                  expansions
                                                                                                                                                                                                  • unroll
                                                                                                                                                                                                    expr
                                                                                                                                                                                                    (|Ordinal.<<_102| (|Ordinal.Int_93| (|count_`inbound_msg list`_3772|
                                                                                                                                                                                                                                   …
                                                                                                                                                                                                    expansions
                                                                                                                                                                                                    • unsat
                                                                                                                                                                                                      (let ((a!1 (>= (no_client_id_88 (|get.NewOrder.0_3714|
                                                                                                                                                                                                                                        (|get.::.0_…

                                                                                                                                                                                                    5. Complete examples

                                                                                                                                                                                                    Now let's have a complete example that shows how to insert and then trade outright and strategy orders

                                                                                                                                                                                                    In [32]:
                                                                                                                                                                                                    let m4 = {
                                                                                                                                                                                                    
                                                                                                                                                                                                      curr_time = 1
                                                                                                                                                                                                      
                                                                                                                                                                                                      ; last_ord_id = 0
                                                                                                                                                                                                      
                                                                                                                                                                                                      (* first strategy is 2*x1 - x2 + x3 *)
                                                                                                                                                                                                      ; strat1 = (make_strat 1 2 (-1) 1)
                                                                                                                                                                                                      (* second strategy is just the 3rd outright security *)
                                                                                                                                                                                                      ; strat2 = (make_strat 2 0 0 1)
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* outright books *)
                                                                                                                                                                                                      ; out_book1 = empty_book
                                                                                                                                                                                                      ; out_book2 = empty_book
                                                                                                                                                                                                      ; out_book3 = empty_book
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* Strategy books *)
                                                                                                                                                                                                      ; s_book1 = empty_book
                                                                                                                                                                                                      ; s_book2 = empty_book
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* Inbound and outbound message queues *)
                                                                                                                                                                                                      ; inbound_msgs = []
                                                                                                                                                                                                      ; outbound_msgs = []
                                                                                                                                                                                                    } in
                                                                                                                                                                                                    
                                                                                                                                                                                                    (* Helper function signature is: 'cid inst qty sd p'*)
                                                                                                                                                                                                    let new_ord1_msg = make_no_msg 1 (Outright OUT1) 100 SELL 75 in
                                                                                                                                                                                                    let new_ord2_msg = make_no_msg 2 (Outright OUT1) 75 BUY 80 in
                                                                                                                                                                                                    let new_ord3_msg = make_no_msg 3 (Outright OUT1) 125 SELL 50 in
                                                                                                                                                                                                    
                                                                                                                                                                                                    run m4 [new_ord1_msg; new_ord2_msg; new_ord3_msg];;
                                                                                                                                                                                                    
                                                                                                                                                                                                    Out[32]:
                                                                                                                                                                                                    - : market list = [<document>; <document>; <document>]
                                                                                                                                                                                                    
                                                                                                                                                                                                    Strategy 1
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Strategy 2
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Book 1
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    -
                                                                                                                                                                                                    75 (100)
                                                                                                                                                                                                    Book 2
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Book 3
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Strategy 1
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Strategy 2
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Book 1
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    80 (75)
                                                                                                                                                                                                    75 (100)
                                                                                                                                                                                                    Book 2
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Book 3
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Strategy 1
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Strategy 2
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Book 1
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    80 (75)
                                                                                                                                                                                                    50 (125)
                                                                                                                                                                                                    -
                                                                                                                                                                                                    75 (100)
                                                                                                                                                                                                    Book 2
                                                                                                                                                                                                    BuysSells
                                                                                                                                                                                                    Book 3
                                                                                                                                                                                                    BuysSells